I'm attempting to import a simple Excel data table into a strongly typed IEnumerable in C#. I'm using FileHelpers ExcelNPOIStorage engine to do this, assuming this won't require Excel to be installed on the user's machine (as the deprecated ExcelStorage option requires).
private T[] UseExcelNPOIStorage(string filename, bool skipFirstRow = true, int startColumn = 1)
{
ExcelNPOIStorage provider = new ExcelNPOIStorage(typeof(T), filename, skipFirstRow ? 1 : 0, 1);
provider.Progress += Provider_Progress;
provider.ExcelReadStopBehavior = ExcelReadStopBehavior.StopOnEmptyRow;
provider.ExcelReadStopAfterEmptyRows = 2;
provider.StartRow = skipFirstRow ? 1 : 0;
try
{
return (T[])provider.ExtractRecords();
}
catch (Exception ex)
{ }
return null;
}
When using the method listed above, I receive an "Index was outside the bounds of the array" exception. Am I missing something?