npoi-examples icon indicating copy to clipboard operation
npoi-examples copied to clipboard

How to set .hasError for dtRow

Open rdasgupta7141 opened this issue 3 years ago • 0 comments

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?

rdasgupta7141 avatar Mar 17 '21 23:03 rdasgupta7141