Reputation: 3559
I want to read an unformatted contents of the numeric cells (e.g. 0.05
instead of 5%
and 123456
instead of 123,456.000
).
I thought the easiest way to do it would be to change the format of the cell:
ICell cell = ...;
string s = cell.SetCellType(<ICell.CELL_TYPE_STRING-doesn't compile>).ToString();
but I do not know how to set string/numeric format.
All examples I have googled are either from POI
or HSSF
universes, they won't do for me (I am reading Excel 2007
spreadsheet using NPOI
)
Upvotes: 2
Views: 871
Reputation: 3559
This worked for me:
string formatProofCellReading(ICell cell)
{
if (cell == null)
{
return "";
}
if (cell.CellType == CellType.NUMERIC)
{
double d = cell.NumericCellValue;
return (d.ToString());
}
return cell.ToString();
}
Upvotes: 2