20 Jun 2016

NPOI :: Cannot get a text value from a numeric cell

While working with NPOI in VB.NET to read data from Excel file as a string value, sometimes you might face the above-mentioned error.

This is because the data in the excel file might be in different format. For example, it can be  a date OR it can be a number.

To get rid of this error, I found a simple solution here which I am giving briefly below.

Dim DF AS New DataFormatter()
Dim CellObj AS Cell = WorkSheetObj.GetRow(RowIndex).GetCell(CellIndex)
Dim CellVal AS String = DF.FormatCellValue(CellObj)

No comments:

Post a Comment