Private Function GetCellValue(ByVal sht As HSSFSheet, ByVal RowNum As Integer, ByVal ClmNum As Integer) As String
Dim
CellValue As String = String.Empty
Dim row As HSSFRow = sht.GetRow(RowNum)
If row IsNot Nothing Then
Dim cell As HSSFCell = row.GetCell(ClmNum)
If cell IsNot Nothing Then
If
cell.CellType = NPOI.SS.UserModel.CellType.STRING Then
CellValue
= cell.StringCellValue
ElseIf cell.CellType = NPOI.SS.UserModel.CellType.BLANK Then
CellValue
= cell.StringCellValue
ElseIf cell.CellType = NPOI.SS.UserModel.CellType.NUMERIC Then
If HSSFDateUtil.IsCellDateFormatted(cell) Then
CellValue = cell.DateCellValue
Else
CellValue = cell.NumericCellValue
End If
ElseIf cell.CellType =
NPOI.SS.UserModel.CellType.BOOLEAN Then
CellValue
= cell.BooleanCellValue
ElseIf cell.CellType = NPOI.SS.UserModel.CellType.ERROR Then
CellValue
= cell.ErrorCellValue
ElseIf cell.CellType = NPOI.SS.UserModel.CellType.Unknown Then
CellValue
= cell.StringCellValue
ElseIf cell.CellType = NPOI.SS.UserModel.CellType.FORMULA Then
Select Case
cell.CachedFormulaResultType
Case
NPOI.SS.UserModel.CellType.NUMERIC
CellValue = cell.NumericCellValue
Case
NPOI.SS.UserModel.CellType.STRING
CellValue =
cell.StringCellValue
End Select
End If
End If
End If
Return CellValue
End Function