5
I have a program that reads data from a text file and exports it to an excel report.
I have a problem in the transcription of the 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’s the code
//trim porquê o número vem com alguns espaços
string content = itensCarac[indexColumnText].Replace(",000000", "").Trim();
planConfig.Cells[indexLine, indexColumn++] = content;
Turns out there are numbers in the report in that format:
4.700,000000
In theory the same logic would work. but Excel sees this number as "4.7" (God knows why), it "turned" the point into a comma and killed the 00.
If I don’t apply this logic to the rows where there is a floating point, excel treats them as text, and converting excel to number solves the problem. How the image below shows
That is the question:
How to do this conversion from text to number via code in the correct way?
OBS:
I’ve tried using the
NumberFormat = "0.0";
or the
NumberFormat = "0";
and the results were "4.7"
It worked!!!! the results were exactly as expected with this implementation. Thank you very much !!!
– Guilherme Golfetto