Quantcast
Channel: NPOI
Viewing all articles
Browse latest Browse all 1621

Commented Unassigned: Issue with DataFormatter [12959]

$
0
0
I'm processing excel file with custom format. In my excel file I have a column store number with custom format _(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_). when using NPOI to read value from this column using DataFormater is got values wrong, the values alway have a * character in prefix
* 103,456.00:
* 3,455,555.00
* 12,345.00
* 6,543.00
* 3,234.00
* 2,234.00
* 322.00

here my code:
public static void NPOITest()
{
HSSFWorkbook hssfworkbook = null;
using (FileStream file = new FileStream("D:\\testpoi.xls", FileMode.Open, FileAccess.Read))
{
hssfworkbook = new HSSFWorkbook(file);
}
ISheet sheet = hssfworkbook.GetSheetAt(0);
// HSSFDataFormat format = (HSSFDataFormat)hssfworkbook.CreateDataFormat();
HSSFDataFormatter formater = new HSSFDataFormatter();
for (int i = 0; i < sheet.LastRowNum; i++)
{
IRow row = sheet.GetRow(i);
ICell cell = row.GetCell(0);
Debug.WriteLine(string.Format("{0}", formater.FormatCellValue(cell)));

}

}
Comments: ** Comment from web user: tonyqus **

You should use NumericCellValue to read the numeric value in one cell


Viewing all articles
Browse latest Browse all 1621

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>