LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Exprot 1D array to excel as a column after last column

I have an 1D array llike as following

 

1

2

3

4

5

6

I want export it into the excel sheet after last column,

x x 1

x x 2

x x 3

x x 4

x x 5

x x 6

 

I only found get the last rows function

 

Thanks.

0 Kudos
Message 1 of 3
(3,075 Views)

Because of the way arrays are written to disk, it is very complicated to append a column. Essentially the entire file must be rewritten for every column.

 

If you do not need to read the file until all the data has been collected, just append rows. After the data collection is complete, read the entire file, transpose the 2D array, and write it back to the file. It may be safer to keep two files, one to which data is appended by rows, and the trasnposed final file. If the file must be available to be read whiel data collection continues, the two file method is useful to avoid situations where a read occurs while only part of a column has been modified.

 

Lynn

0 Kudos
Message 2 of 3
(2,925 Views)

If you are using the Report Generation Toolkit and really writing an Excel File (.xls, .xsx), this is pretty straight-forward.  Here is code that basically writes an array of six numbers in column format, one column at a time, adding the next column to the right of the previous column (and recalculating, so you could use the same logic for your original question.  The key step is to use Excel Easy Table, which accepts a 2D table (I create a 6-row by 1-column 2D representation of a single column, with the first element being the column index to aid identification) and lets you specify the location (Start) of the first cell (by default it is 0, 0).  It also returns the "next Starting Row" and "next Starting Column" as outputs, so I simply use the latter and save in a shiftt register for the "next column".

Excel by columns.png

Bob Schor

0 Kudos
Message 3 of 3
(2,912 Views)