I'm trying to return the cell value from an excel file and I am able to receive the value but right after returning the value it gives me a System.ArgumentOutOfRangeException. It's confusing since the program was able to receive the data and show me in a Windows Forms Message Box but it still gives me the error that I went out of range.
public static void RemoveUpdates()
{
//Grabs data from excel file by given file path
IWorkbook wb = new XSSFWorkbook("INSERT FILE PATH HERE");
ISheet ws = wb.GetSheetAt(0);
//iterates through each row of the excel file
for (int x = 1; x <= ws.LastRowNum; x++)
{
IRow row = ws.GetRow(x);
//Opens a windows forms message box to present the data received from the cell
MessageBox.Show(row.Cells[6].ToString());
}
}
Error: System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index'
Any help would be appreciated