I'm trying to get the column index using the column name, but if I enter a column name which is not in the dataset then I get an exception. How do I handle this?
string columnName ="ABC";
int ColumnNumber-0;
if(ws.Cells["1:1"].First(c => c.Value.ToString() == columnName ).Start.Column!=Undefined)
{
ColumnNumber=ws.Cells["1:1"].First(c => c.Value.ToString() == columnName ).Start.Column;
}