10-18-2024 09:24 AM
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
Generate table subvi
Excel Generate report table vi
Numeric format
10-18-2024 09:46 AM - edited 10-18-2024 09:49 AM
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.
10-18-2024 10:10 AM
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.
10-18-2024 10:23 AM - edited 10-18-2024 10:30 AM
@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.
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 "þ"
10-21-2024 10:42 AM
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