LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Excel truncating zeros when I read a worksheet

Solved!
Go to solution

What is the name of the function, palette that you are wiring to the output of the Excel Get Active X References VI?

0 Kudos
Message 11 of 19
(1,794 Views)

It's called Excel_Get_range.vi and is a subVI of Excel_Get_Data.vi which is used to get the array of DBLs there. I opened up the Get Data VI and copied it from there. You could alter the Get Data VI to just output the reference since it already has it there for you, but that would be altering a VI from the palette that you may use elsewhere, so that's not advisable.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 12 of 19
(1,782 Views)

I will try your solution and let you know.  The Excel spreadsheet I gave you as the example Rounds to 4 digits and then is formatted as a number with a precision of 4 decimal places.  My code truncates the trailing zeros, I will try your code and see if it yields a different result.

0 Kudos
Message 13 of 19
(1,779 Views)

Also, if you're unfamiliar with VI Snippets, you can drag and drop the code above on to a block diagram to actually import the code. You may know this though, and just don't have 2014 LV?

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 14 of 19
(1,776 Views)

Very Cool!  Thanks for letting me know I could just drag and drop to import your code.  I was not aware of that capability.  So I take it you are suggesting that I read the data and check against the value in the formatting output. Then reformat the value that has the zeros truncated back to the precision based on formatting?

0 Kudos
Message 15 of 19
(1,764 Views)

I guess the piece of information I'm still missing from you is how you're displaying the data and why you need the trailing zeros.

 

If you're displaying as strings, I could understand that. In order to match the precision that way, I would use a Number to Fractional String native to do the conversion and use the Precision input based on the formatting you got from excel.

 

If you're displaying as a DBL, then you need to use a property node for your indicator to match the formatting from excel.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 16 of 19
(1,758 Views)

Here's how you could format the DBL format:

Excel Truncated Zeros FormatString .png

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 17 of 19
(1,744 Views)

I am actually taking the data from the Excel spreadsheet and formatting it into text files which can then be imported into our LIMS system.  Since these are reported results (ASTM Standard)  they need to match the precision from the spreadsheet.  In this context 0.91 is not equal to 0.9100 is not equal to 0.9100000000000003

0.91 is an 'implied' precision and the people viewing the data don't want to assume the precision, but need to see it displayed exactly according to the ASTM standard.

Hopefully, this clarifies my issue.  I take it you are then suggesting that I read the value and the precision (from Excel) and then format the data back to the precision I want?

0 Kudos
Message 18 of 19
(1,721 Views)
Solution
Accepted by Nova2

If the way that the data is formatted in excel is your standard and you need to pass that formatting on, then yes. The disadvantage of this is that someone could forget to format the excel sheet, or put the wrong precision in there.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 19 of 19
(1,717 Views)