LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

insert Text in excel

Solved!
Go to solution

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.

 

RvG_1-1601928800723.png

 

Download All
0 Kudos
Message 1 of 7
(2,910 Views)

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

0 Kudos
Message 2 of 7
(2,898 Views)

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.

0 Kudos
Message 3 of 7
(2,867 Views)

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

0 Kudos
Message 4 of 7
(2,862 Views)

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

0 Kudos
Message 5 of 7
(2,860 Views)

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:

RvG Excel Problem.png

[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.

RvG Excel Front Panel.png

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:

RvG Excel Output.png

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

Message 6 of 7
(2,801 Views)
Solution
Accepted by topic author RvG

With the RGT you can format the cells as "text" as in the following snippet. The default used by Excel is "standard", it will recognize number and format them as number accordingly.

 

Excel Set Cell Format to Text with RGT.png

 

Ben64

Message 7 of 7
(2,790 Views)