Yu Zhang
Yu Zhang

Reputation: 2149

How to read the trailing zero from Excel

I am reading data from an Excel sheet as test data,

But when I read the two cells, I got 17.5 and 52.5 respectively.

Anyone has a solution?

Upvotes: 1

Views: 107

Answers (1)

Garrison Becker
Garrison Becker

Reputation: 482

If all your needing to do is display 17.5, as 17.50 and are always expecting 2 decimal places, you can do the following:

excelValue.ToString("#.00", CultureInfo.InvariantCulture);

Upvotes: 2

Related Questions