From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Weird format behavior when writing numbers in Excel cells

Solved!
Go to solution

Hi guys,

 

I'm trying to wrap my head around a weird problem:

I write a 2D array of double (decimal delimiter is a comma, so 1/100 is 0,01) into an Excel Workbook. I created this file "Test.xlsx" by hand and did not change anything regarding formatting of the cells.

excel vi code.PNG

But what I get in Excel is this:

excel screenshot.PNG

 

 

Why

1. is cell A1 different in formatting from all other cells (format and justification)

2. are the values of those other cells wrong? There seems to be a problem with the decimal delimiter.

 

Thanks for your input!

0 Kudos
Message 1 of 6
(3,014 Views)

The problem is on Excel side.

Has nothing to do with LabVIEW.

You can fix it in Excel manually.

 

Does Excel say number saved as text ?

Can you format the cell to number ?

 

George Zou
0 Kudos
Message 2 of 6
(2,995 Views)

Thanks for your reply.

But regardless of how I format the cells in Excel, the outcome is still wrong.

 

From 0.01 (1/100) in LabView it goes to 1000 in Excel in all cells but A1.

0 Kudos
Message 3 of 6
(2,942 Views)
Solution
Accepted by topic author joptimus

zou>> I do not think so, I think it is yet another situation where NI has not thought about countries that do not have the same decimal separator as the US.

 

joptimus>> The solution is to feed the array through "Number to Fractional String" with the setting "use system decimal point" = false and then feed it to Excel Easy Table.

Then it will work.

Message 4 of 6
(2,914 Views)

Perfect, you saved my day! Thank you!

 

One follow up question remains though:

Can I somehow write an 1D array into existing Excel cells? The "easy table" VI seems to accept only 2D arrays.

0 Kudos
Message 5 of 6
(2,904 Views)

You can simply feed the 1D array into "Build array", then it will become a 2D array.

0 Kudos
Message 6 of 6
(2,886 Views)