LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

write data to excel file, problem with data format

Hello all, I'm a beginner on labview 13.0, since a few months.

 

I am trying to write datas on excel sheet, but the format does not work properly. I enter for example %5.5f for floats, but the VI does not take it into account. Am I doing it wrong ?

 

(See code attached)

 

Many thanks in advance

 

Thibaud

 

 

0 Kudos
Message 1 of 9
(2,917 Views)

Note : in order to reproduce the problem, you have to select a folder and create an excel file named "try"

 

thanks

0 Kudos
Message 2 of 9
(2,912 Views)

You appear to have uncovered a "mis-implemented Feature" (I don't want to call it a "bug" ...).  I followed the data through the RGT Functions down to the place they are actually passed to Excel -- they are translated into Strings, using the formats you designated (%5.5f), and at that step, the String values do, indeed, have the requested format.  However, when the data appear in Excel, not all of the String contents show up.  For example, B1 has 0.00555 instead of 0.0055454.  I am not certain why this should be the case -- I intend to ask NI about this ...

 

Bob Schor

0 Kudos
Message 3 of 9
(2,874 Views)

thank you for your answer !

 

 

Do you know any other way, I can correctly write in excel  the data of my example ?

 

Thibaud

0 Kudos
Message 4 of 9
(2,869 Views)

Oops -- I meant to add a suggestion for your Code Development.  I replaced the initial building of the Excel File slightly, as shown here:

Create Excel Name.png

You will notice two changes.  First, I changed the Label of the Path Control to "Sélection du dossier" instead of making this the caption and leaving the Label as "Path" -- this makes it easier to find the control on the Block Diagram, which helps make the code more "self-documenting".  Also, notice that using Build Path saves several steps and makes combining a Path + Filename to be a new Path also intuitive and self-documenting, making your code more readable and maintainable.

 

Bob Schor

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

Double-oops -- I was completely wrong (it happens ...).  Excel and the RGT are "mostly" doing the Right Thing, other than allowing the wrong Default Format to be used in the Worksheet (but if you are using a Template, as specified in the Original Post, you can override the default Column Format and allow the precision you wish).

 

The only column that presents a problem of digits not making it to Excel is the one I mentioned, B1, where 0.0055454 become 0.00555.  However, if you consider that the requested format was %5.5f, which asks for 5 digits to the right of the decimal point, then 0.0055454 does, indeed, become 0.00555.  If I change the format string to %5.7f, I get all the digits into Excel.

 

Bob (Embarrassed) Schor

0 Kudos
Message 6 of 9
(2,827 Views)

Dear Thibaud,

 

     I hope my "Double-Oops" response shows you what you need.  If you use %5.7f as your Report format, you will get all of the digits into the Excel Worksheet.  Now, if you open the Worksheet and look at the data displayed, you can decide if you like the existing format or if you want to click on the top of the column and change it, remembering to save the file (as it will be used as a Template the next time you run the program).

 

Bob Schor

0 Kudos
Message 7 of 9
(2,815 Views)

It does not work for me, maybe it's about my excel configuration.. the comma is not detect on excel.

0 Kudos
Message 8 of 9
(2,778 Views)

Please, Thibaud, don't attach pictures, but attach code.  [You might notice the picture in my earlier post -- that is a "Snippet", which you create from LabVIEW's Edit menu using Save Selection as Snippet -- it looks like a .PNG file, so you can display it, but you can also drag it into a LabVIEW Block Diagram and it magically becomes LabVIEW code].

 

What I think is wrong is the "decimal symbol" setting.  On this side of the Atlantic, we usually use the period, while in Europe, it is not uncommon for the comma to be used.  Needless to say, if there is disagreement over who controls the decimal symbol, you will have problems.

 

Because I can't test your code directly, I can't suggest what to change, but look at those settings.

 

Bob Schor

0 Kudos
Message 9 of 9
(2,743 Views)