10-05-2020 03:16 PM - edited 10-05-2020 03:30 PM
I am using the standard sample of ExcelExamples.llb.
Write Table To XL.vi
When I fill in 1, 1.1, 1.1.1 it is all converted into the excel file. When I try to insert 1.10, excel shows 1.1
This is because excel reads it as a number. How can I write it as an text. I need this, because I am making a conversion from an item list with values like 1.1, 1.2 , .... 1.9, 1.10, 1.11 etc. But the issue is, i receive a 1.1 on the place of the 1.10.
Solved! Go to Solution.
10-05-2020 03:33 PM
Thank you for attaching this Example so we could try it for ourselves, and explain exactly the misunderstanding you are having. Oops, you didn't attach this example (which must be ancient, if it is using an .llb file).
Here's what I'm guessing is happening -- Excel is choosing to format your data with a single decimal point, so the value that you input of 1.11 is displayed as 1.1. Of course, I'm unable to test the code you failed to attach, but that's my "best guess".
Bob Schor
10-05-2020 04:52 PM
I could not open some of the files because they are saved for LV 2019. But, you can try to add an apostrophe ' before the number so that Excel interprets it as text. Also, if you have the Report Generate Toolkit available I would try to use that instead.
10-05-2020 04:56 PM
Hello Bob,
I am sure the issue is excel write the 1.10 as 1.1 because of the decimal. But is there a way to add a property of text to a cell (using Active X??)
By writing 1.10.1 excel sees it as a text part. In excel I can use the '1.10 to create a text, but it doesn't work from labview.
So the question remains.
Rens
10-05-2020 04:58 PM
Hello Gregory, thanks for thinking with me. But the apostophe ' is not working. When I put it in front, it is also printed in excel. So the result in excel is '1.10
Rens
10-08-2020 12:33 PM
I copied your Table to a fresh VI, wrote a little bit of code to (a) display the Text Array you call "Table", (b) converted this Text Array to an Array of Dbls, just to see how LabVIEW interprets the value in Row 1, Column 4, which is the Text String "1.10.1" (not a legitimate number), then wrote a little routine using 6 LabVIEW functions to save these data to Excel (it worked, by the way).
Here is the code, saved as a Snippet:
[I didn't count the functions I used to convert the String Table to a Number Array in my count of 6 functions, above ...]. Look at the four functions on the bottom -- Create Report, Excel Easy Table, Save Report to File, and Simple Error Handler.
Here is the Front Panel, showing the Table, and what it looks like as an Array of Strings and as an Array of (LabVIEW-recognizable) numbers.
Note Row 1, Column 4, which has the string 1.10.1, not a valid LabVIEW Number. LabVIEW converts this to the (legal) number 1.1, as shown on the bottom array. But what does Excel do with this?
Here is the contents of the resulting Excel file:
Excel does exactly the right thing. All of the (string) data except Row 1, Column 4, are recognized as numeric, and appear as numeric quantities, left-justified. However, the string "1.10.1" is not a valid number, so it is saved as a string (note that this is right-justified).
I'm not sure if this "solves" your problem. The bottom line is that if you want Excel to accept a Table as numeric values, then be sure that all of the values in the table are legitimate numbers.
Bob Schor
10-08-2020 03:54 PM