This project has moved and is read-only. For the latest updates, please go here.

InsertRow not working...

May 13, 2012 at 9:39 PM
Edited May 14, 2012 at 12:26 AM


I am having some trouble trying to insert a row into sheets (using the latest version of EPPlus).  Any ideas on what the issue might be?

I get the Error:

Specified argument was out of the range of valid values.Parameter name: Start cell Address must be less or equal to End cell address


This is the code:


                MemoryStream ms = new MemoryStream();
                byte[] template = ModelBuilder.Properties.Resources.template;
                ms.Write(template, 0, template.Length);

                FileStream fs = new FileStream(outputFileLoc, FileMode.Create);
                p = new ExcelPackage(fs, ms);

                p.Workbook.Worksheets["myname"].Cells["A1"].Value = "test";
                p.Workbook.Worksheets["myname"].Cells["B1"].Value = "test";
                p.Workbook.Worksheets["myname"].InsertRow(1, 1);


And this is the stacktrace:

   at OfficeOpenXml.ExcelAddressBase.Validate()   at OfficeOpenXml.ExcelAddressBase.SetAddress(String address)   at OfficeOpenXml.ExcelAddress.set_Address(String value)   at OfficeOpenXml.ExcelRange.get_Item(String Address)   at OfficeOpenXml.ExcelWorksheet.AddFormulas(List`1 added, Int32 position, Int32 rows)   at OfficeOpenXml.ExcelWorksheet.FixSharedFormulasRows(Int32 position, Int32 rows)   at OfficeOpenXml.ExcelWorksheet.InsertRow(Int32 rowFrom, Int32 rows, Int32 copyStylesFromRow)   at OfficeOpenXml.ExcelWorksheet.InsertRow(Int32 rowFrom, Int32 rows)

May 14, 2012 at 12:26 AM

Figured out the problem.  There was a defined name cell it couldn't find (fyi).