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

Cannot re-save the existing xls file after modifying the value of some cells

Mar 4, 2014 at 6:02 AM
Hi, I am trying to open the existing spreadsheet, modify the values of some cells and re-save the xls but I have the error saving the file. The InnerException said "Package object was closed and disposed, so cannot carry out operations on this object or any stream opened on a part of this package.".

The code is just simple like
            using (package = new ExcelPackage(existingXLS))
                // get the first worksheet in the workbook
                worksheet = package.Workbook.Worksheets[1];  

               //modify the values of some cells          
    for (int i = 2; i <= numRows; i++)
                   worksheet.Cells[i, 10].Value = newvalue1;
                   worksheet.Cells[i, 11].Value = newvalue2;

Can you please help? Thank you.