Using EPPlus ExcelPackage to read the excel sheet
var newRow = table.NewRow();
newRow["Reference"] = row[rowNumber, 1].Text;
newRow["AssessmentTitle"] = row[rowNumber, 2].Text;
newRow["AssessmentDate"] = row[rowNumber, 3].Text;
newRow["AssessmentLabel"] = row[rowNumber, 4].Text;
newRow["Likelihood"] = row[rowNumber, 5].Text;
newRow["Impact"] = row[rowNumber, 6].Text;
In the above code, I have mentioned the rowNumber and column number to read the cell, however, now the header is dynamic. They can be alter in any order.
How do I read the value based on dynamic column ?
I think you could try create a dictionary to record column number and text of startrow. I tried as below:
Tried with the excel:
The Result: