LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

copy to excel

Right now I have a vi named Write to Excel.vi which writes data from 3 2-d arrays into 2 separate workbooks and saves them. I have another vi named worksheet.vi which renames the worksheet to the current date. I am trying to place the data into different worksheets according to the date. So if the write to excel.vi is ran, I would like it to be saved to a new worksheet if the date has changed. As of now everytime i try to run the worksheet.vi, it overwrites my data and leaves me with a blank worksheet with just the date. I have attached both vi's, if anyone could guide me as to how I should do this that would be great.
 
Thanks,
 
Nick
Download All
0 Kudos
Message 1 of 10
(3,605 Views)

Hello Nick,

It looks like your main problem is that your "Write to Excel.vi" does not actually write to an Excel formatted file. It looks like you're using the "Write to Spreadsheet File(strings).vi" to get your data to disk. This VI writes the data a ASCII data formatted in a way Excel can read it. (tab or comma delimited) This is an assuption because you did not attach your version of "Write to Spreadsheet File(strings).vi". If you've modified this VI to write to Excel using ActiveX, then please attach it so we can have a look at what's going on.

I think what is happening is that you are writing an initial file, opening it with your "worksheet.vi" to set the sheet name (probably works) but then you write to the same .xls file using the "Write to Excel.vi" again. But since this just writes basic text and not real Excel, the original file is just overwritten.

If you have the Report Generatikon Toolkit, you can easily use the VI's from that to write directly to an Excel formatted file targeted to a specific sheet and do what you need. If not, you'll need to build a VI that uses ActiveX to write to Excel.

This Dev Zove article has an example that should get you started.

Let us know how it works out for you.

Ed



Ed Dickens - Certified LabVIEW Architect
Lockheed Martin Space
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 2 of 10
(3,585 Views)
Hi Ed,
 
Thanks, the link you gave me was very helpful. I've now correctly added the data into the excel file. I still have a few more questions. Is there a function that checks if a file is already been created? For example if channel1.xls has already been created i just want to keep adding new pages to the workbook. My other question is, is there a way to pull the data from the same arrays instead of having them in each of the separate vi's?? i will attach the new vi's which i created. Here is an explanation of what each vi is supposed to do.

excel.vi - It's the main vi that runs all other vi's. In the first frame, It creates a workbook and names it. The second frame creates a new page and labels it the current date and time.
EunitTitle.vi - labels each column in the worksheet.
EunitValue.vi - enters in the data in column 1 of the Eunit array.
VoltValue.vi - enters in the data in column 1 of the Volts array.
CountValue.vi - enters in the data in column 1 of the Counts array.
EunitValueCh2.vi - enters in the data in column 2 of the Eunit array.
VoltValueCh2.vi - enters in the data in column 2 of the Volts array.
CountValueCh2.vi - enters in the data in column 2 of the Counts array.
 
Thanks,
Nick
Download All
0 Kudos
Message 3 of 10
(3,558 Views)
 
Download All
0 Kudos
Message 4 of 10
(3,556 Views)

Message Edited by Nick_C on 02-20-2007 03:26 PM

0 Kudos
Message 5 of 10
(3,558 Views)
 
Download All
0 Kudos
Message 6 of 10
(3,556 Views)

To check if a file already exists, you could use the "File/Directory Info" function found on the 'File IO>Advanced File Functions' palette. Give this function a path and if the file is not there, the function will generate an error with a code of 7. This indicates a File not Found error. No error indicates that the file does exist.

I'm not sure what you mean in your second question. You can pass an array into a subVI using a control connected to a terminal. Can you give a few more details on what are you trying to do?

Ed



Ed Dickens - Certified LabVIEW Architect
Lockheed Martin Space
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 7 of 10
(3,547 Views)
Hi Ed,
 
There is a 2d array in the EunitValue.vi, VoltValue.vi, CountValue.vi, EunitValueCh2.vi, VoltValueCh2.vi, and CountValueCh2.vi,  The arrays are the same for each corresponding vi. For example, the 2d array in EunitValue.vi has the same values as the 2d array in EunitValueCh2.vi Is there a way to just have 3 separate 2d arrays and place them in the excel.vi file? Then just link the arrays to the correspond vi? I hope this explains it a little better.
 
Thanks,
 
Nick
0 Kudos
Message 8 of 10
(3,544 Views)

I eluded to the answer in my last reply, but I guess you didn't catch it.

What you need to do is connect the 2D array control on the front panel of the subVIs to a terminal on the icon/connector pane. Then you can create either a block diagram constant or front panel control of the arrays and connect them to the new terminals you created on the subVIs.

Ed



Ed Dickens - Certified LabVIEW Architect
Lockheed Martin Space
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 9 of 10
(3,529 Views)
Thanks for all your help Ed. The program runs the way I wanted it to.
 
Thanks again,
 
Nick
0 Kudos
Message 10 of 10
(3,512 Views)