Discussion:
combine multiple excel files
(too old to reply)
AshishMaharjan
2008-08-04 16:10:05 UTC
Permalink
I am using Write To Spreadsheet File.VI to create an excel file. How can I create multiple worksheets in an excel file created using this VI?
OR
If I create multiple excel files using Write To Spreadsheet File.VI , how can I combine them to create single excel file?
 
Thanks for help.
 
Ravens Fan
2008-08-04 16:10:08 UTC
Permalink
Write to Spreadsheet file in my opinion is somewhat misnamed.  It doesn't truly make spreadsheet files that you think of like an Excel file.  They aren't Excel files.  It makes a text file with delimiters separating data elements and rows.  Tab delimited or comma delimited with end of line characters to break up the rows.  This can be imported into Excel, but would be done one sheet at a time.
 
If you truly want to make Excel files, search the forums for examples using ActiveX to call Excel.
AshishMaharjan
2008-08-06 18:10:07 UTC
Permalink
Since my path in the Write to Spreadsheet File.vi is is C:\....abc.xls file, this will create an excel file. The advantage I found on this was it would write 2D array very fast. I need to add another 2D array in another worksheet. Can I do this while using Write to Spreadsheet File.vi?
If not, I was wondering if I could instead write my two 2D arrays using Write to Spreadsheet File.vi and then combine these two.
Right now I am reopening that abc.xIs file using activeX, adding worksheet and writing 2D array using for loop (screenshot attached) which has more than 1000 rows and more than 50 columns. This takes a very long time.
Any suggestions?
Thanks.


writing_2d_array_using for_loop.JPG:
http://forums.ni.com/attachments/ni/170/347210/1/writing_2d_array_using for_loop.JPG
smercurio_fc
2008-08-06 18:10:08 UTC
Permalink
AshishMaharjan wrote:
Since my path in the Write to Spreadsheet File.vi is is C:\....abc.xls file, this will create an excel file. No it won't. As already pointed out, that VI does not generate an Excel file. It generates a text file. These text can be opened with Excel simply because Excel can read text files. But they're text files, not Excel workbooks. The advantage I found on this was it would write 2D array very fast. I need to add another 2D array in another worksheet. Can I do this while using Write to Spreadsheet File.vi?No. This has already been pointed out. That VI does not generate Excel files. If not, I was wondering if I could instead write my two 2D arrays using Write to Spreadsheet File.vi and then combine these two.
Right now I am reopening that abc.xIs file using activeX, adding worksheet and writing 2D array using for loop (screenshot attached) which has more than 1000 rows and more than 50 columns. This takes a very long time.
Any suggestions?
Write the values using the Range object instead of each cell at a time.
Ravens Fan
2008-08-06 18:10:09 UTC
Permalink
AshishMaharjan wrote:

Since my path in the Write to Spreadsheet File.vi is is C:\....abc.xls file, this will create an excel file.


This is NOT an excel file.  It is a text file that you just happened to give an .xls extension.  It will open in Excel when you double click it because .xls extensions are registered to Excel.  Excel then recognizes it as a text file it can import and will do so.
 
There is no way to create a text file using Write to Spreadsheet file that is equivalent to more than 1 Excel worksheet page.
 
You will have to use the ActiveX functions if you want to create a true Excel file that has multiple worksheets from within LabVIEW.
 
You could write out each 2-D array to separate text files using the Write to Spreadsheet File VI, then use ActiveX methods to open them within Excel and merge the sheets together into a common workbook.
Loading...