LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Excel numeric format

Hello,

I'm generating tables with numeric data in excel using excel functions from the report generation toolkit. I format the numeric data into string values with four digits of precision before writing to excel file, however, for zero data values, the trailing zeros are removed. I will like to check every data and if it is a zero value then programmatically format it with trailing zeros before writing to excel. Please what would be the best approach to accomplish this? The code that I currently have does not do that. I had to know the specific cell ID ahead of time and then pass in that cell ID. I want to automatically retrieve the ID and I'm not sure how to get around this problem. All suggestions are appreciated.

Thanks in advance!

 

Excel file

excel numeric format2.PNG

Generate table subvi

Excel Generate report table vi

Generate table2 subvi BD.PNG

Numeric format

excel numeric format BD.PNG

0 Kudos
Message 1 of 5
(172 Views)

The format specifier string should be "%.04f

 

HINT: you can always test your format specifier strings by playing with the Display Properties of a FP control.


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 5
(162 Views)

Hello JpB,

Thanks for your response. I had the format set to %.04f before I posted the on the forum. The format specifier didn't seem to be making any difference. Here is where I'm generating the data that I write to the excel file blow.format specifier code.PNG

0 Kudos
Message 3 of 5
(147 Views)

@SolPS wrote:

Hello JpB,

Thanks for your response. I had the format set to %.04f before I posted the on the forum. The format specifier didn't seem to be making any difference. Here is where I'm generating the data that I write to the excel file blow.format specifier code.PNG


Display format specifiers simply Change how data displays and do not change the data values. 

 

When you write numeric data to a cell in excel the actual data value is sent.  Then, since you can also tell excel how to display that data (as you did in your first post) excel can display that data however you want.   

Unfortunately, you stuck a littoral "0.0000" in the cell format specifier and that is wrong! To display 0.0000 (with a data value of @0) the specifier should be "%.04f"  since you specified a invalid specifier Excel saw a string containing only numeric characters and displayed it as numeric data by default.   You SHOULD sent the data as a dbl.

 

And that's a Thorn. As in Jay Thornby alt+0222 on your PC or long-press "t" on Android for "þ"



"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 5
(139 Views)

Hello JþB,

My apologies for messing up your name spelling..lol..., Anyways, I tried your recommendations but unfortunately, it didn't work for me. Perhaps I may not be understanding you correctly.  I contemplated sending DBL values but the Excel Easy text function that I use to write to the excel file does not accept doubles.  I changed the 0.0000 value that I wired to the numericformat method shown in my earlier post to ".%04f" but it didn't work. Perhaps a quick example or screenshot from you will be helpful.  

Thanks

0 Kudos
Message 5 of 5
(88 Views)