LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

exporting data to excel

I have created an automated test where I work. I have gotten most of it finished. I am having trouble when I export my data to excel. I have tried adjusting the column widths and formatting some of the text. Once I save it and close excel kt reverts back to all the original settings. Any help would really be appreciated.
 
Thank You
Chris Gallo
0 Kudos
Message 1 of 19
(4,470 Views)

Hi Chris,

i can´t see the code to set the width of a cell, but i also think it is not possible with the "write to spreadsheet file" function. If you really need to set the width of the columns, you have to use ActiveX to do that.

Mike

0 Kudos
Message 2 of 19
(4,436 Views)
Hi Chris,

All you are doing with the "Write to Spreadsheet" VI is writing a text file in xls (Excel) format. You are not actually controlling anything in Excel at all. If you wanted to have more control over actual Excel you would need to use ActiveX commands.

Please refer to the following link for information about the ActiveX calls to Excel.

http://msdn.microsoft.com/en-us/library/aa176808(office.11).aspx
Eli S.
National Instruments
Applications Engineer
0 Kudos
Message 3 of 19
(4,418 Views)
Dear Chris,

To programmatically set the width of a column in Excel, you should use the ColumnWidth property of the Range object.  I used the Office 2007 objects for this screen shot, but I think the method and property names are very similar, if not the same, for the 2003 Object Library that Eli linked.  I hope this points you in the right direction.




Message Edited by Pie56694 on 06-06-2008 05:38 PM
0 Kudos
Message 4 of 19
(4,404 Views)
Steve, Thanks for your input I now have a different approach. Just one question for you though. I have designed the post you put up and when I run the vi i get an error code 3005 from the automation open connected to Excel._Worksheet. Also is there any text materials that you know of that discuss the ActiveX usage in LabVIEW.
 
Chris Gallo
0 Kudos
Message 5 of 19
(4,371 Views)
Hi chris,
remove the open "Automation Open" function which is in front of the "Variant to Data" function. You don´t need to open it, you need the reference only as type description.

Mike
0 Kudos
Message 6 of 19
(4,365 Views)
Hey  Mike, Thanks for the quick response.
 
Chris
0 Kudos
Message 7 of 19
(4,356 Views)
 
 

Chris,

Here are some links to material on ActiveX in LabVIEW.

ActiveX/COM Overview 
ActiveX and LabVIEW
Using ActiveX with LabVIEW
Re: Reading Tables in MS WORD using LabView & ActiveX

I hope this helps.

Mike,

Thank you very much for the catch!  Oops!



Message Edited by Pie56694 on 06-10-2008 03:23 PM

Message 8 of 19
(4,341 Views)
OK next question. I can get excel to format the way I need it to, but when I try to write new data into excel it writes over the existing data. Any advice on how to get it to write the data to each line everytime I run the vi.
 
Thanks
Chris Gallo 
0 Kudos
Message 9 of 19
(4,299 Views)
Hi chirs73,
i don´t understand what you mean. Can you explain please? If you write to a cell then you overwrite the data, a solution could be to first read the cell, then concatentate the new and the old one and write the result back to the cell you read from.

Mike
0 Kudos
Message 10 of 19
(4,297 Views)