06-15-2015 02:24 PM
Hi. I am trying to build a VI that creates a 2d array (3 rows and 100 columns) and writes the transposed data to a spreadsheet file. The only kicker is I have to add headers to the spreadsheet. I have figured out how to create the array and send it to the spreadsheet without headers, but I cannot figure out how to get the headers in there.
06-15-2015 03:04 PM
Are you trying to send the file to Excel, or write a text file that "looks like" a Spreadsheet? For the former, use the Report Generation Toolkit. Its Table output functions include headers. For the latter, you should probably do two Writes, a 1D for the Header and a 2D for your data.
Bob Schor
06-15-2015 03:08 PM
Hi Bob. Trying to send it to Excel itself. I have been using the write to spreadsheet block and saving it as a csv file and opening it in excel.
06-15-2015 03:09 PM
Hrader are strings and you can't mix strings and double in an array.
You can convert the double to string before writing to the spreadsheet file.
Not that the Write to Spreadsheet vi it will create a text file, not an Excel file. To create an Excel file the report generation toolkit is the easyest way, the other way is to use ActiveX methods and properties.
Ben64
06-15-2015 03:22 PM
Here's how you would do it using the report generation toolkit.
06-15-2015 05:01 PM
Actually, you can mix Reals and Strings, just not in the same Write to Spreadsheet call. This was the solution that I had in mind:
Bob Schor
06-15-2015 05:11 PM
Oops, didn't notice the error in the RGT solution -- forgot to take transpose of the array. Just for fun, I also used the Append Table to Report function.
BS
06-15-2015 10:29 PM
I actually need three headers. One above each column (since it becomes 100 rows and 3 columns after transposing it). I tried doing a string array and connecting it to a write spreadsheet and then connecting that to the write spreadsheet like you showed in this example and the headers did work in the first spreadsheet (I tested that on its own first), but when the second write to spreadsheet was connected the it wiped out the first one so only the numbers in the 100x3 array were displaying.
06-15-2015 10:44 PM
06-15-2015 10:52 PM
That was the problem, thanks!