LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how can I creat or open an excel file in labview?

I am using Labview 7.1 and report generation toolkit. I got the example code from this address :"Creating a report in Microsft excel using the labview report generation toolkit"
But seems this example only can creat report when the excel file exist, otherwise it will get error code 7.

How can I creat a new file if it doesn't exist and open the file if it exist? Can I creat a report without openning excel because I need to creat more than one report and check it after the test.

Thanks
0 Kudos
Message 1 of 4
(3,470 Views)
hi ya-hoo,

Try deleting the template path and leaving a blank field. The vi is calling for a file that does not exist, but if you leave the template file path blank, the "New Report.vi" should open a blank excel sheet without any problems. Otherwise, you need to create the template file and path, which you have already discovered.

Hope this helps.
Message 2 of 4
(3,470 Views)
Hello,

In response to your question: "How can I creat a new file if it doesn't exist and open the file if it exist?"

Try using the "Open/Create/Replace" VI. This VI can be found on the File I/O palette. Right-click on the "function" input and create a constant. Click on the drop-down arrow for the enum and select "open or create". If you use this function, the VI will open a file if it exists, and create it if it does not. It will not return an error as long as you have the "file path" input wired.

Hope this helps!

Liz F
National Instruments
Message 3 of 4
(3,470 Views)
Simply use the "Open/Create/Replace File.vi, and wire a constant "Create / Replace".

Wire a path/filename and make sure the name ends with the extention .xls

If you have multiple lines (likely), place aech line in an array and use the "Array to Spreadsheet String.vi" before sending it to "Write to file.vi". Don't forget to close the file.

Hope this helps..

JLV
Message 4 of 4
(3,470 Views)