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: 

Loss of very small order values during excel exportation

Solved!
Go to solution
Solution
Accepted by topic author mattecst

@mattecst wrote:

I don't really need an excel file what I need a convenient and organized table where I can see al the values.

Is it possible with the .csv?


Definitely. Look at the function aputman mentioned (Write to Spreadsheet File or Write to Delimited File). That should do what you want.

European separators and Excel can be a bit tricky so you may want to use tabs instead of commas.

0 Kudos
Message 21 of 28
(1,444 Views)

@Taki1999 wrote:

@aputman wrote:

You don't really export an excel file with this function.  You may be naming it with an XLSX file extension but it is just a delimited text file.  You can confirm whether it's excel causing the issue by opening the file in a text editor.  


With the Express VI, it looks like it does actually export an Excel file. Write to Measurement File actually creates binary files. Write to Spreadsheet or Write Delimited create much happier text delimited files.


I'm not sure where you got this information from, unless that is a new feature in Labview > 2012.  Attached is an output from Write to Measurement FIle.  It's definitely text format.  

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 22 of 28
(1,437 Views)

It is an Excel file XLSX.  That is an option that was added to the Write to Measurement File in one of the more recent LabVIEW versions.

 

I've drilled down into the code of the Express VI.  I can't describe how far I got down to be able to guide you to it.  But I'm looking in a subVI that can be found at this path:

 

C:\Program Files (x86)\National Instruments\LabVIEW 2015\vi.lib\express\express shared\NI_ExcelFile\SubVIs\fmt_formatSingleCell (Numeric).vi

 

 

In there it formats the number to a string using a format string of %.6f  (thus the truncated data.)  This format string gets defined in a subVI a bit up the line.  (See attached screenshot.)

 

I think there is a bug in the Excel implementation of the Write to Measurement File where it isn't defining the correct format string for these numbers.

 

Someone from NI,  please investigate deeper.

 

In the meantime, I think you'd be better off not using this express VI.  Write it as a text file using your own formatting functions.

 

EDIT:

Aputnam:  here is an image from LV 2015 showing the Excel option

 

Download All
0 Kudos
Message 23 of 28
(1,425 Views)

But you can't assign a name to the values youre exporting right?


Since I have 14 different types of value in the VI naming every one was useful 

0 Kudos
Message 24 of 28
(1,417 Views)

@mattecst wrote:

But you can't assign a name to the values youre exporting right?


Since I have 14 different types of value in the VI naming every one was useful 


Sure you can.  Keep an array of names.  Do a single write of that string array to the file to make a header row as one of the first things you do before writing out the data in a loop.

0 Kudos
Message 25 of 28
(1,413 Views)

I'm sorry but I'm kinda noob I started using labview for the first time one week ago. 

 

As you saw I have the array of string that are the names of the values and the array of the values who keeps updating as long as the VI runs. 

Where am I supposed to link them to the Write to Spreadsheet File function?

 imma.png

0 Kudos
Message 26 of 28
(1,396 Views)

@RavensFan wrote:

 

EDIT:

Aputnam:  here is an image from LV 2015 showing the Excel option

 


Fair enough.  Sucks having an older version of software.  Smiley Mad

 

Change the format to .lvm and when the export is done, rename the file to .txt.  Open the text file up in Excel and it respects your columns, headers are there, no data loss, etc.  

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 27 of 28
(1,381 Views)

Use a single instance of that subVI before your loop.  Wire the array into the 1-D array terminal.  It is polymorphic so it will adapt to an array of strings as opposed to an array of numerics.

 

For your function in the loop, you can use that same function, make sure you wire a True to the Append to File input.  Make sure your format code is %g.

 

Though if you need to have different formating for every column, you'd be better off using a Format Into String and defining the format for each element that is going into that string.

 

Now the Express VI has some nice features as hiding some code that allows you to give files a new name if the current filename exists already.  If you need those functions, you'll need to write your own code that will detect whether a file exists, and comes up with a new name if it does.

 

You can write click on an Express VI and pick Open Front Panel.  When you do that, you see the actual code in the background that is doing all the work.  It is a nice way to get a start on some complicated code that you can then adapt to your own needs.

Message 28 of 28
(1,370 Views)