LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

writing to an Excel file

I am collecting digital on/off boolean data from four cDAQ9181. Currently I am using write to text file, but I set the extension to csv because I would like to open them using Excel. I attach the vi.

It works ok but when I build an exe file and run it, the file dialog does not show me the file extension (which instead appears if I run the source code) 

Ideally, I should write the data to an xlsx file directly. I was given different suggestions (tdms, write to measurement file…) but they don't seem to fit my case. What would you suggest me? Thanks

0 Kudos
Message 1 of 8
(2,503 Views)

Hi Davide,

I opened your VI to try to reproduce your issue, but I wasn't able to do so because the ReadDigitalInput subVI is missing. Could you please send it in attachment, too?

Best regards,

Alessia

0 Kudos
Message 2 of 8
(2,346 Views)

yes you are right! sorry about that, I attach it here . Thanks 🙂

0 Kudos
Message 3 of 8
(2,341 Views)

I am pretty sure i did it.. let me try again, 

0 Kudos
Message 4 of 8
(2,340 Views)

Now I can run the VI, thanks; it creates a CSV file whose name is "today's date".csv. However, it's not clear to me how the behavior of the executable differs from that of the source code, sorry... Could you please send a couple of screenshots explaining what happens when you run the source code and when you launch the executable?

Regards,

Alessia

0 Kudos
Message 5 of 8
(2,332 Views)

It actually happens on the production PC and right now I have no access to it. 

Basically, it does not add the csv extension to the newly created file…

But still, the ideal solution would be to write the data to an Excel spreadsheet.

Thanks a lot!

0 Kudos
Message 6 of 8
(2,328 Views)

Hi Davide,

 


@DavideB wrote:

But still, the ideal solution would be to write the data to an Excel spreadsheet.


Then there are several options:

  1. Use RGT functions to write to a XLS(X) file. You need MSOffice installed on your production PC.
  2. Use ActiveX to remotely control Excel to create your XLS(X) files. You need MSOffice installed on your production PC.
  3. Use 3rd party software like XLR8 (see VIPM) to create XLS(X) files. No need for MSOffice on the production PC…
  4. Create XLSX files from scratch as they are mainly ZIPped XML files. No need for MSOffice on the production PC…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 8
(2,319 Views)

I wonder if you are using the Express VI improperly (its documentation is a little confusing, and it might have some strange behaviors).  You are supplying a default name (a string representing today's date), and specify a pattern-matching for existing files of ".csv" (which, as it turns out, will match no existing .csv files -- you would need to specify "*.csv" to match existing files).

 

You are also making the (very common for LabVIEW users) mistake of confusing text files that follow a row/column method (called "Comma-Separated Values", or "csv"), which Microsoft's Excel Spreadsheet program can open, as can any Text editor, with the proprietary Workbook Files that Excel uses, with the extension .xlsx.  If you are only storing numeric data in regular rows and columns, I recommend using LabVIEW's Delimited Spreadsheet VIs that write .csv files (though the LabVIEW default method uses <tab> characters as column separators, though you can specify a <comma> to get a "true" .csv format.  Excel doesn't care -- it usually figures out what separator you are using.

 

Bob Schor

0 Kudos
Message 8 of 8
(2,269 Views)