LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

number stored as text

Solved!
Go to solution

Hi~

when write a table to MS Excel, the number all stored as text as you can see green flag on left top corner of each cell, this is cause the fomula in upper cell un-workable.

123.png

 

the code that used to write excel as below:

code.png

 

have you even seen this before? pls advice, thx!


"I think therefore I am"
0 Kudos
Message 1 of 10
(3,824 Views)

Hi ELI,

 

so you write a string array to an Excel range - and now you wonder why those strings are displayed as strings? Really???

 

Write a 2D array of DBL when you want to store numbers in an Excel sheet…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 10
(3,816 Views)

Hi GerdW,

but the table also contained string like date/ operator name, only the test result is number (show in below). 

e.png

 

Thanks,

Eli


"I think therefore I am"
0 Kudos
Message 3 of 10
(3,810 Views)

Hi ELI,

 

and what's the problem then?

Write the strings as strings. Write the numbers as numbers. Handle them different!

 

(You might use even more ActiveX nodes to tell Excel on how to interpret each column of data. I don't think it will be easier this way.)

 

Lesson learned: Provide all needed information in the first place, not piece by piece…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 10
(3,804 Views)

then it will slow down the process of saving to excel file follow your way.

 

just like the code I used before, in this way, the string and number can correct show in Excel, but in this way we waste much time to write excel, bcs the table was written to cell one by one.

 

Untitled.png

 

can we solve this error in LabVIEW? with activeX.. 

 


"I think therefore I am"
0 Kudos
Message 5 of 10
(3,796 Views)
Solution
Accepted by topic author ELI2011

There's a hack you can use - after you write the values, read the data from the Value2 property and write what you just read back to the property (so it's write A, read B, write B). I don't know why, but this works. Probably some quirk in how Excel auto-formats types.


___________________
Try to take over the world!
Message 6 of 10
(3,786 Views)

Hi ELI,

 

but in this way we waste much time to write excel, bcs the table was written to cell one by one.

Nobody mentioned to write cell by cell. You still can write full columns or even 2d arrays of data - you just have to separate strings from numbers!

 

can we solve this error in LabVIEW? with activeX..

There is no error in LabVIEW. And there is no error in Excel. It's an error in your programming!

 

By now you got two different solutions presented, how much more do you need?

 

I thought you learned a lesson by now. But you still feed us with breadcrumbs of information with each of your posts: Now you bring the execution time into play…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 10
(3,757 Views)

its amazing, and it really helped!

just read back then write it again, the error disappered.

 

thank you very much!

 


"I think therefore I am"
0 Kudos
Message 8 of 10
(3,737 Views)

not learned a lesson, I am already known these (your suggestion) before! now the issue was solved by tst (Knight of NI).

 

anyway, thanks for your reply, though it not helped. 


"I think therefore I am"
0 Kudos
Message 9 of 10
(3,723 Views)

lol

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 10 of 10
(3,651 Views)