npoi-examples
npoi-examples copied to clipboard
How to set .hasError for dtRow
I need to add some validations to the parsing Excel to DataTable process. for (int i = firstDataRow; i < sheet.PhysicalNumberOfRows; i++) { var sheetRow = sheet.GetRow(i); if (sheetRow == null) { continue; } var dtRow = fileDataTable.NewRow();
for (int colNumber = 0; colNumber < numberOfColumns; colNumber++)
{
var cell = sheetRow.GetCell(colNumber, MissingCellPolicy.CREATE_NULL_AS_BLANK);
dtRow[colNumber] = cell.GetFormattedCellValue();
//TODO:validation of the row }
fileDataTable.Rows.Add(dtRow);
}
How do I add validation to make sure required cells are not left blank or null? And more importantly how do I set HasError, RowError with the message?