I recently upgraded from 4.0.5 to 4.1.0 and noticed this error
The following code results in exception "row cannot be less than 1"
int xlRow = 18;
using (ExcelPackage xl = new ExcelPackage(pfReport, template))
{
var wb = xl.Workbook;
ExcelWorksheet sht = wb.Worksheets[1];
--> sht.InsertRow(xlRow, 1);
xl.Save();
}
Note that the template file contains text in cells below row 18
When rolling back to version 4.0.5 the code runs normally
Comments: In our case in turned out that it was an invalid NamedRange in the Excel template. You can check this by hitting CTRL+F3 in Excel. Search for #REF! in de Value column. After deleting this NamedRange the problem was solved. Error message is misleading because it suggests your parameters are invalid. Code fix would be something like checking for invalid namedRanges (in ExcelNamedRangeCollection.cs Insert method, in the for...each loop).
The following code results in exception "row cannot be less than 1"
int xlRow = 18;
using (ExcelPackage xl = new ExcelPackage(pfReport, template))
{
var wb = xl.Workbook;
ExcelWorksheet sht = wb.Worksheets[1];
--> sht.InsertRow(xlRow, 1);
xl.Save();
}
Note that the template file contains text in cells below row 18
When rolling back to version 4.0.5 the code runs normally
Comments: In our case in turned out that it was an invalid NamedRange in the Excel template. You can check this by hitting CTRL+F3 in Excel. Search for #REF! in de Value column. After deleting this NamedRange the problem was solved. Error message is misleading because it suggests your parameters are invalid. Code fix would be something like checking for invalid namedRanges (in ExcelNamedRangeCollection.cs Insert method, in the for...each loop).