LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String data into an Excel file

I want to write string data into an Excel file in the following manner

 

 Untitled.jpg

thanks

0 Kudos
Message 1 of 16
(8,736 Views)

Hi salmanabid,

 

use WriteToSpreadsheetFile...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 16
(8,708 Views)

If you would like an actual Excel file (*.xlsx) and have a new enough version of LabVIEW (2013 or higher), you can use the Write to Measurement File express VI and select the Excel file output option.  If you would like headers on your columns, you can set these using the Set Dynamic Data Attributes express VI before wiring the data to the write VI.

0 Kudos
Message 3 of 16
(8,681 Views)

... and if you have the Report Generation Toolkit, you can do lots of "fancy stuff" with Excel, including making plots and formatting your Workbook.

0 Kudos
Message 4 of 16
(8,650 Views)

@DFGray wrote:

If you would like an actual Excel file (*.xlsx) and have a new enough version of LabVIEW (2013 or higher), you can use the Write to Measurement File express VI and select the Excel file output option.  If you would like headers on your columns, you can set these using the Set Dynamic Data Attributes express VI before wiring the data to the write VI.


Wow this is quite interesting.  Opening the Express VI gets a little crazy but it appears that NI is making this xlsx file without using Excel, and just writing to the text file using the standard XML format that Excel accepts.  Very cool.  In the past I have always created a TDMS file, then used ActiveX and Excel to convert from TDMS to XLSX.  This has its benefits but takes time at the end for the conversion.

 

It would be really cool if NI cleaned up the Excel writing code a bit and made it an official API for creating/editing Excel files without ActiveX.

0 Kudos
Message 5 of 16
(8,640 Views)

Thanks but still hav not got propr solution, i m using Labview 2009 and  also used write to excel block but didn't got the desire output as i hav attached image above.. just tell me how to separate each line from string.

0 Kudos
Message 6 of 16
(8,634 Views)

Hi salma,

 

did you tried to write an array of separate strings instead of your one string instead? Have you tried anything so far?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 16
(8,629 Views)

Hooovahh wrote:

It would be really cool if NI cleaned up the Excel writing code a bit and made it an official API for creating/editing Excel files without ActiveX.


I believe there is a suggestion on the Idea Exchange to that effect.  Please kudo it.  Making it an official API is somewhat challenging because XLSX files are compressed.  To add or modify them, you need to uncompress to a temp location, modify, then recompress.  This makes streaming to an XLSX file a challenge.  It also accounts for the time hit when the file is closed - it has to be recompressed.  An API would allow the user to explicitly do the uncompress and recompress, making streaming much easier.

 

For the original question, if you don't mind a text file, open a text file and write each line, including the header, using tabs as separators between the columns.  You have both string and numeric data, so you cannot use the standard array to spreadsheet string VI or the write to spreadsheet VI (at least not easily).

0 Kudos
Message 8 of 16
(8,622 Views)

Thanks 

0 Kudos
Message 9 of 16
(8,588 Views)

Hello Salamabid,

 

Have you tried using a Build Array.vi for each string you want to enter and then inputting that information into an Array To Spreadsheet String.vi?

 

Take a look at the attached example. The data may not be entered in a way that you want but you can use the String Subset.vi and other string manipulation VIs to format the strings the way you want.

Noah | Applications Engineer | National Instruments
0 Kudos
Message 10 of 16
(8,571 Views)