I had to get excel data into DataTable
example copied from this. If the column name is an empty string, when data is getting into DataTable
the empty name is converted into a dynamic name like F1, F3, F22. If the column name has a valid value it's okay, but when I try to get column name of empty column name, dynamic F22 name is getting. F22 doesn't exist in the excel sheet, I have to inform the user that he has empty column name which is not valid.
So the question is how to tell if column name is dynamic set by the OLEDB?
DataColumnCollection excelDataColumns;
....
for (int i = 3; i < excelDataColumns.Count; i++) {
var columnName = excelDataColumns[i].ColumnName;
// Check if column name is blank
if (IsExcelDefaultColumnName(excelDataColumns[i], i))
{
invalidEntries.Add("Blank column name");
}
else
{
var result = IsValidData(GetFullData(columnName));
if (!result.Item1 && !columnName.Any(char.IsDigit))
{
invalidEntries.Add(columnName);
}
}
}