‎12-20-2011 08:59 AM
So I have four arrays being generated by different AO subsystems, three graphs and one table of various sizes. My program runs, I hit the stop button which ends the readings, and I want a save button that pulls up excel and saves the file.
Currently I have it where it just exports them all using invoke nodes, but this is rather inconvienient. I was thinking somehow using activex and local variables for the arrays, but Im not well versed enough to do this without a little guidance. There are a few things specifically I would like this to do if it's possible. (Listed in priority to the project.)
1) Save each array to different workbooks within the same excel file.
2) Automatically save the document as a .xlsx file (I only say this because currently the default seems to be .txt)
3) Have an automatically generated path (in my case /Desktop/Labview Reports/Excel/ ) and file name (preferably "'Date' Data Run '1 (2, 3, etc.)'"
4) Finally if possible I would like it to automatically save the file and leave it open for user interaction rather than close it.
If anyone can help I would greatly appreciate it!!
If anyone could post an example code where I could add in variables for my arrays that would be even better!! Thank you all very much in advance!!!
‎12-20-2011 10:46 AM
Just to clarify, I meant save to multiple worksheets, not workbooks, within one excel file. Thanks!!
‎12-20-2011
01:10 PM
- last edited on
‎04-26-2025
10:47 PM
by
Content Cleaner
The Report Generation Toolkit can do this for you.
Or, you can try to program Excel yourself using ActiveX. There's an example that ships with LabVIEW that writes a table to an Excel workbook. For more examples you can look in the Excel thread. NOTE: DO NOT POST QUESTIONS IN THE EXCEL THREAD.
‎12-20-2011 03:23 PM
It seemed a little bit of an overkill to get the report generation tool when this is the only instance that i need to use it... And i've seen examples of writing to an excel file before, but im really not sure how to specify additional worksheets, and the file extension, etc.
‎12-20-2011 05:11 PM
You'd get the workbook's Sheets collection and use the Add method to add a sheet. Look at the example that ships with LabVIEW.
‎12-21-2011 02:23 PM
The examples likely being referred to are the "Excel Macro Example.vi" and "ActiveX Event Callback for Excel.vi" shipping examples. As smercurio mentioned though, although you can do what you want without it, the report gen toolkit makes formatting much easier. Also, in terms of saving as an .xls file, the Write to Spreadsheet File.vi might be the function you are looking for.
Chris G
‎12-21-2011 03:58 PM
There are a lot of examples on the Excel Board. Have a look at all the examples posted there. Try them out and if you get stuck more let us know.
For more information and some sample VI's and tool kits, you can go to the excel board
‎12-22-2011 07:15 AM
I think we're going to just go ahead and get the report tool kit after all... It seems like youre right in that it'll make it significantly easier on us! So thanks for everyones help, ill just come up with some temporary code for saving until the PO can go through!!