I've read a file with NPOI and in one column I have some number values and some char values. I need to check if this Cell contains a char value (like "stop"), and if so then I don't want to read this. This is what I've tried:
if (sheet.GetRow(row) != null and sheet.GetRow(row).GetCell(2).Substr(0,4) != "stop")
{
Console.Write(sheet.GetRow(row).GetCell(1));
}
However I can't read char and number values using this code.
its bit tricky. See the below approach to read the value. Convert your read value into string object like this sheet.GetRow(row).GetCell(1).ToString();
XSSFRow row = (XSSFRow)sheet.GetRow(i);
for (int j = row.FirstCellNum; j < cellCount; j++)
{
if (null != row.GetCell(j) && !string.IsNullOrEmpty(row.GetCell(j).ToString()) && !string.IsNullOrWhiteSpace(row.GetCell(j).ToString()))
{
Console.Write(row.GetCell(j).ToString());
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With