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.
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.
03-09-2016 03:08 PM
@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.
03-09-2016 03:13 PM
@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.
03-09-2016 03:15 PM - edited 03-09-2016 03:23 PM
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
03-09-2016 03:20 PM
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
03-09-2016 03:21 PM
@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.
03-09-2016 03:30 PM
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?
03-09-2016 03:34 PM - edited 03-09-2016 03:35 PM
@RavensFan wrote:
EDIT:
Aputnam: here is an image from LV 2015 showing the Excel option
Fair enough. Sucks having an older version of software.
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.
03-09-2016 04:01 PM - edited 03-09-2016 04:04 PM
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.