LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to save excel report as CSV file with ActiveX

Solved!
Go to solution

To clarify -- do not simply post a JPG picture of a tiny piece of your code -- we need to see the whole thing, and in executable form (i.e. as a .vi, or at least as a Snippet), so we can understand the context of what you are trying to do.

 

BS

0 Kudos
Message 11 of 17
(2,034 Views)

Hi all,

 

I already have a working code that generates .xls file. It is a subvi in a larger application.  The issue here is that some users wanted a csv file so I'm trying to modify my subvi code to do that. See attached zip file.

 

Thanks

0 Kudos
Message 12 of 17
(1,994 Views)
I can't look at the code now. As already mentioned here and in that thread you linked to, the simplest way to create a csv file is to use the Write to Spreadsheet File function. The data you pass to the Excel wrote can also be passed to it in parallel or with a case statement. Simple and direct without messiing around with Excel's ActiveX. To find the ActiveX method or property, there are numerous Microsoft forums.
0 Kudos
Message 13 of 17
(1,989 Views)

As long as you are using the Report Generation Toolkit, there is no need to use ActiveX for the purpose of saving the Excel file -- Save Report will do that for you.  You can then export (as text) all of the Excel data and use the Write Spreadsheet File to make the .CSV file.  Here is how I would rewrite the final bits of your code --

Create CSV Report.png

I cleaned up the wires around Excel Easy Table a bit.  You'll see I made a VI Icon for Replace Filename, which does (I think) a nicer job of self-documenting than showing its Label.  To make the filename, add the correct extension (.xlsx for Excel, .csv for CSV), use Build Path to combine Folder and Filename, and wire to Save Report.

 

The next two functions add the Extract Everything and Write to Spreadsheet, using a Comma as a separator, which makes a CSV copy for you.

 

Bob Schor

0 Kudos
Message 14 of 17
(1,977 Views)
I would just wire the test data directly to the the Write to Spreadsheet instead of exporting it from the Excel file.
0 Kudos
Message 15 of 17
(1,968 Views)
Solution
Accepted by topic author SolPS

That would also work, but would just get the Test Data.  The Original Poster went to some trouble to create headers and fancy formats for the Report -- the CSV can't capture the formatting, but it can get the headers.  As always, it is up to the Programmer to decide what data to export ...

 

BS

0 Kudos
Message 16 of 17
(1,956 Views)
Solution
Accepted by topic author SolPS

 

Thanks everyone. You guys are the best.

0 Kudos
Message 17 of 17
(1,938 Views)