I have a program that reads data from a text file and exports it to an excel report.
I have a problem with transcription of numbers, in the txt file I have data in this format:
8,000000
This value should be regarded as 8 (number) by the report, so I made a routine to remove this "000000" and it works, here is the code
//trim porquê o número vem com alguns espaços
string content = itensCarac[indexColumnText].Replace(",000000", "").Trim();
planConfig.Cells[indexLine, indexColumn++] = content;
It turns out there are numbers in the report in this format:
4.700,000000
In theory the same logic would work. but Excel views that number as "4.7" (You know why), it "turned" the point into a comma and killed the 00.
If I do not apply this logic to the lines where it has a floating point, excel treats them as text, and converting excel to number solves the problem. As the image below shows
Here'sthequestion:
Howtomakethistext-to-numberconversionviacodetherightway?
NOTE:
I'vealreadytriedusing
NumberFormat="0.0";
or the
NumberFormat = "0";
and the results were "4.7"