Example Code

LabVIEW Report Generation Toolkit [RGT]: Use comma as decimal separator when exporting to Excel.

Code and Documents

Attachment

On an OS that uses commas as decimal points, the Append Table to Report.vi does not correctly push the numeric data to Excel (CAR#130447). In the VI NI_Excel.lvclass:Append Numeric Table to Report.vi the numeric data is converted into a spreadsheet string and then converted into a two dimensional array of strings.  When this is written to Excel, we get different results - all of them are wrong. Wrong can mean a variety of things, including warnings saying the data is text, too many decimals or commas, commas being interpreted as the thousands separator, etc.

Bug.png

Work-around:
Before calling the Append Table to Report, convert the numeric array to a spreadsheet string.  Then replace all commas with periods, and convert to a two dimensional array of strings. Then feed the two dimensional string array into the Append Table to Report VI. The excel settings will now dictate how to display the numbers in Excel, and the data will all be read in as numeric.

Work-around.png

Attached is the VI in LabVIEW2012 version. If you need an earlier version of the VI, just create your own based on the screenshot above.

Special thanks to Ryan DelGizzi for assistance with this work-around.

Best Regards

Alex E. Munkhaus
Certified LabVIEW Developer (CLD)
System Engineer

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Samgut
Member
Member
on

Thanks, this works great!

gregorelectric
NI Employee (retired)
on

Hi,

I found a much simpler solution, just format the string by a prefix: "%.;":

Solution.PNG

Contributors