LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to simplify addition of data into spreadsheet when using a .csv instead of a .xlsx?

Solved!
Go to solution

I modified one of the Beginners ActiveX Toolkits provided by Joe_H to enter a number into a spreadsheet using the following code "Save to Existing Spreadsheet.vi".  However, since it was originally designed for a .xlsx, it uses an input for the sheet index (which I have set to 1 when using my .csv file).  Currently, the program is working, but I was wondering if there is a way to remove the sheet index part.  I tried just deleting it, but I could not find how the connections for refnums etc should then work out.  Thank you for any advice, even if it is just to say that nothing major should be done.

 

 

0 Kudos
Message 1 of 9
(3,023 Views)

Does it need to be active X? You can use the write to spredsheet vi and that would make things really easy for you.

 

 Example.png

Tim
GHSP
0 Kudos
Message 2 of 9
(3,016 Views)
I'm not sure if it needs to be active X, but the reason I went in that direction was to put the data in a specific place.  I would write data as a program went along, and then later go back and fill in a blank position once the program had completed.  I was unable to use write to spreadsheet file.vi to do that (as it either makes a new one, or appends to the end), so used active X because that had the ability to input data where I chose.
0 Kudos
Message 3 of 9
(3,013 Views)

You can do that with a write to spredsheet too. You need to change the 2D array before saving.

 

Example.png

Tim
GHSP
0 Kudos
Message 4 of 9
(3,008 Views)
Since there was a large quantity of data, there is no array containing all the data to use "Replace Array Subset" on.  Instead I just have the data input into the spreadsheet file periodically, appending as it continues.  I could read all the data back from the spreadsheet into an array, and then add the additional point, but I felt that would be unnecessarily slow for my purposes.
0 Kudos
Message 5 of 9
(3,002 Views)
So when you replace data do you just replace a row? a cell? What kind of replacement are we talking about here? I can see what I can do with Active X if I know better what you are trying to accomplish.
Tim
GHSP
0 Kudos
Message 6 of 9
(2,995 Views)

I will be replacing a blank, single cell with a numeric value.  The blank value is created in a header, which I already will have created.  The position of this replaced cell will always be constant (say for example it is location A5).  Thank you for the effort you are putting in to help me with this issue, I'm sorry if I wasn't clear from the beginning.

0 Kudos
Message 7 of 9
(2,989 Views)
Solution
Accepted by M. Bobby
I do not believe that there is a much easier way to do what you want then the code that you provided.
Tim
GHSP
Message 8 of 9
(2,971 Views)

You seem to be fundamentally confusing a .csv file and a .xlsx file. A .csv file is nothing but a text file. A .xlsx is an Excel workbook format. What you are doing with the code you posted is basically having Excel open the .csv file and treat it as a workbook. When you save it, it will still be a text file with a .csv extension. If you want to use Excel to replace specific cells then what that whole mess is what you have to do because that's the Excel object model.

 

I think that the Write to Spreadsheet File will be far easier. You do not need to read in the whole file if you just want to append values. The Write to Spreadsheet File has an "append to file" input. All that this does is simply move the file pointer to the end of the file. 

0 Kudos
Message 9 of 9
(2,958 Views)