LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need simple example for writing to Excel

HI
I appreciate your time and help,but I still can not downlloado it.
please send to my email :           meirener0118@sina.com.cn
0 Kudos
Message 11 of 47
(3,929 Views)

Gonna bring this thread back from the recently deceased...hey, it's Halloween!

Having trouble writing to an excel file while trying to work your examples into my code.  In my code, I have my spreadsheet writing to a refnum.  (Previously, I was writing to a txt file.  Now I'm trying to do the same thing, just converting the txt file into a spreadsheet so I can use certain cells for certain chunks of data.)   When I wire my refnum into the reference input of the Invoke Node tool, it tells me I'm wiring a "byte stream file reference" into a "automation reference of class".  I've tried all sorts of conversions, but it seems like no matter what I do, my input type does not match the expected input.  File type, pathnum, reference, refnum, automation reference.....ARRGGHHH!  Doesn't matter what I use, it's always wrong!!

I've included the chunk of code where I'm trying to write a value to cell C3 in my spreadsheet.  How do I get my input refnum to match what the Invoke Node tool is expecting??

********************************************
Amateur programmer for over 10 years!
********************************************
0 Kudos
Message 12 of 47
(3,915 Views)

Hi,

Can you show me how you make this refnum. Open Excel, open workbook... and so on.

Besides that the property node Value is now Value2 on my PC

0 Kudos
Message 13 of 47
(3,910 Views)

Here's where the file (and refnum) is originally created.  It was originally a txt file and I'm in the process of changing it to an xls spreadsheet, so it looks a little goofy for now.  I want to get it working as a spreadsheet before I start cleaning things up.

 

Ahhhh, who am I kidding?  When do you ever really get time to go back and clean up a program?

********************************************
Amateur programmer for over 10 years!
********************************************
0 Kudos
Message 14 of 47
(3,909 Views)

I was afraid of that, you have to do much then just open a file. See the Excel6.1.zip in reply 10. One of the VI opens a spreadsheet file with ActiveX

Let me know if this helps

0 Kudos
Message 15 of 47
(3,905 Views)

Still doesn't work.  Some quick info - my program is a big stacked sequence, that bounces from case to case depending on test conditions.  In one of my initial cases, I create the spreadsheet.  Rather than continuously opening and closing that spreadsheet in every case, I have created a shift register of the refnum of the file.  I'm trying to use that refnum shift register in another part of the stacked sequence.  It used to work fine with a text file. 

But now when I wire that refnum shift register to the Invoke Node tool, it tells me I'm wiring a "byte stream reference" to a "automation reference of class" input.  I'd like to use the refnum shift register rather than keep reopening the same spreadhseet in each case.

********************************************
Amateur programmer for over 10 years!
********************************************
0 Kudos
Message 16 of 47
(3,900 Views)
The problem is you are trying to write directly to excel. The only way you can do this is with Active X refum not a file refnum. But what you could is build a vi that accepts this refnum. Then inside this vi there would the read from file vi. This vi will accept the file refnum. Then wire the ouput of this vi to the excel vi's that I posted. This is the only way it can be done. (well maybe not) but you cannot use a file refnum with automation open, Try the way that I said and post the vi you create if it does not work. This way you will never close the file refnum you only open and close the Acive X refnum.



Joe.
"NOTHING IS EVER EASY"
0 Kudos
Message 17 of 47
(3,895 Views)
That's what I've been working on - something that takes a refnum of a spreadsheet file and converts it into Active X refnum that the Invoke Node tool will accept.  Haven't succeeded yet, so if anyone has any ideas, please post!!!  Until then, I'll keep chugging away at it!
********************************************
Amateur programmer for over 10 years!
********************************************
0 Kudos
Message 18 of 47
(3,886 Views)


 


@Spaceman spif wrote:
That's what I've been working on - something that takes a refnum of a spreadsheet file and converts it into Active X refnum that the Invoke Node tool will accept.  Haven't succeeded yet, so if anyone has any ideas, please post!!!  Until then, I'll keep chugging away at it!


You cannot convert a spreadsheet file refnum to an Active X refnum it will not work. Are you having trouble using/ getting an Active X refnum for an excel spreadsheet.




Joe.
"NOTHING IS EVER EASY"
0 Kudos
Message 19 of 47
(3,880 Views)

Should I route the File Path into the shift register instead of the refnum?  Would that work?

Yes, I can't seem to create an ActiveX refnum of the spreadsheet.

********************************************
Amateur programmer for over 10 years!
********************************************
0 Kudos
Message 20 of 47
(3,878 Views)