LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I append data to an Excel spreadsheet using ActiveX control?

Hi there

 

I am facing the same issue, can anybody please guide me.

The thing is ,I am trying to store the chart X,Y datas to excel sheet. I can achive this., but only 12 datas is storing in one excel sheet. how to store all data in one excel sheet. I mean , I am not getting how to append the data continuously to one excel sheet. 

 

 

Thanks in advance.

0 Kudos
Message 11 of 23
(2,099 Views)

I have two VIs that I use to accomplish this. I believe I am hitting what you want to do here. The Array_To_Excel.vi takes an array of data and writes it to the spreadsheet given the row and column start cells. The second one Numeric_To_Excel.vi I use in a loop to report data as a test is running that is not in an array. You just have to have a variable that gets initailized at the beginning of the test and then increment it after every write so the next iteration either the row or column would get a new value a far as what cell to write to. I have other versions of both these VIs for numerics, strings as far as the data input depending on what I am saving. It is easy to change as the data coming in is going into a varient so it can be any data type. I hope these help. They have worked flawlessly for me over the years. I have the Array_To_Excel.vi saved the way I do because I call the front panel to be shown when running as I can have thousands of points to save and it can take some time. It simply lets the user know what is going on as I am calling these VIs from TestStand.

 

Troy

Download All
0 Kudos
Message 12 of 23
(2,085 Views)

Hi thanks a lot for the reply.

 

But unfortunately ,I am using labview 2012. can you plz able to upload  the VI which supports 2012..

I really appreciate for your time.

 

 

0 Kudos
Message 13 of 23
(2,073 Views)

If you have access to the LabVIEW Microsoft Report Generation Toolkit, you can find a much easier way to read/write (almost arbitrary) Excel Worksheets without using ActiveX at all!  Given that even Microsoft seems to have abandoned ActiveX development/support (try getting ActiveX help in Windows 7, for example), going the Excel Report Object way seems the way to go.

 

Some comments.  I posted in January of this year (look for Revised "Generate Excel Report" Example) some code that replaces the example that ships with LabVIEW.  I've used Excel quite a bit with LabVIEW, and the new Report Object routines are a lot more User-Friendly than ActiveX!

 

For some reason, the NI "model" of Excel seems to be of a "write-only medium", i.e. a "Report".  Thus there is no analog of "File Open", only "File Create".  However, there is absolutely no problem opening an existing Excel file (with data), reading the data, writing new data (either appending rows to an existing Worksheet, rewriting/overwriting rows in the Worksheet, or creating new Worksheets and adding data) and then saving the file with the same name.

 

There are a few cautions to take, however.  The current LabVIEW "model" of How We Work With Excel (i.e. the "Write-only" model) has a curious bug feature.  Suppose you open an Excel Workbook and write out some data.  You don't Save/Close the Workbook right away, but leave it open on the screen so you can examine what you wrote.  Now, before you ask LabVIEW to Save the Excel file, you click on the red X in the upper right corner of your new Excel Workbook and close it.  Now you exit LabVIEW.  Surprise -- LabVIEW has deleted (!!) your newly-created Excel file!

 

As I noted, this is a "feature" built-in to the Report Save code (which I have brought to NI's attention).  I've devised my own work-around to deal with this bug feature -- before I call the Report Generation "Save" or "Close" routine, I first test if there is an Active Workbook Object (meaning that the Workbook is still open and hasn't been closed "by hand") -- only then do I proceed to allow the Save and Close to occur.

 

Hmm.  So how do I do this test?  Time for the Dirty Little Secret -- I use the Excel Get ActiveX Reference (on the Excel Advanced  Palette) and examine the Excel-._Application ActiveWorkbook property.  If it is not an Empty Path, then it is safe to Save/Close the Workbook.

 

Bottom Line -- you can do quite a bit using the Report-Object tools LabVIEW provides in the Report Generation Toolkit without needing to use ActiveX except in rare instances.  You can treat an Excel spreadsheet as a "file object" that you can read, write, and modify, without needing to worry about "templates" and without needing to adhere to a Write-only model of Report Generation.  A little care is needed, but it is pretty easy to address individual Worksheets, individual rows/coluumns on a Sheet, entire blocks of data, etc.

 

Bob Schor

0 Kudos
Message 14 of 23
(2,065 Views)

I can upload these VIs using 2012 if you still need it. Are you going to pursue Bobs method? If so I do not have to upload the VIs in a earlier version.

0 Kudos
Message 15 of 23
(2,047 Views)

Yes ., Please . I need. Please upload 2012 version.

0 Kudos
Message 16 of 23
(2,043 Views)

Ok here are the files in Labview 2012. Let me know if you need anything further.

Download All
0 Kudos
Message 17 of 23
(2,036 Views)

I saw this thread and was hoping to find a working soultion but I see using ActiveX is still unlreliable and success is machine dependent.

 

I always get this error when using any ActiveX to Excel code I have found

 

Unknown System Error in Numeric_To_Excel_2012.vi

 

This unknown error happens on machines running Windows XP and Excel 2000, Windows 7 and Excel 2010, and Windows 7 and Excel 2013.

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 18 of 23
(2,020 Views)

Thank you Trosier.

0 Kudos
Message 19 of 23
(2,001 Views)

Lot many things I got,which i was not aware of.,as I am new to LabView. Thank you  Bob

Smiley Happy

0 Kudos
Message 20 of 23
(1,998 Views)