11-30-2008 04:58 PM
Hello,
I am using ActiveX to write data of various types to an Excel file. The data will consist of strings, individual numeric values, numeric arrays, and bitmaps.
Is there a way to use the "Range" function to write an array directly? At the moment I am finding that it is necessary to write each individual value of the array to a specific cell using a FOR loop, rather than specifying a range and then wiring the array into "Value2".
I've attached two pictures. When I run the code in the first picture, which uses the FOR loop, the array gets written correctly to the spreadsheet. When I run the code in the second picture, the first element in the array is written to all of the cells in the specified range. (In the examples that ship with LabVIEW, each array element is processed individually using a FOR loop.)
What am I doing wrong in the second picture? Or is it really necessary to write each individual array element to each individual cell in the spreadsheet?
Please do not tell me to use the "Array to spreadsheet string" function. I already know how to do that. I want to know if there is a way to efficiently write the array using ActiveX functions. If not, that's life...but it never hurts to ask!
12-01-2008 08:43 AM
Hi DianeS,
Thanks for the post and I hope your well. I have noticed you so far haven't received any support.
Are you using the Report Generation Toolkit at all? Then take a look at the Sample Report (excel) example - here using a 2D array in a table - so its a data string, it can be written to the xls file.
Using the cells property and the range property you could pass it a 2D array to excel also.
If you could update us and let me know exactly how your writing to xls file that would be great.
Kind Regards,
James.
12-01-2008 09:46 AM - edited 12-01-2008 09:46 AM
Excel is a bit quirky. You have to write it out as a 2D array, remembering to transpose the array. For example:
12-01-2008 10:30 AM
12-01-2008 12:00 PM
smercurio_fc wrote:Excel is a bit quirky. You have to write it out as a 2D array, remembering to transpose the array.
I agree. Microsoft Office tries to do a lot of stuff automatically (because they don't have any faith in the user, probably for good reason), so if you do not input information correctly, it will not read correctly, or at all.