I have an existing excel file that I need to go through and change a cell value depending on the column values around it. Basically, I'm changing the cell values of 1 column. Everything works well until I get to update and then it throws a System.IO.IOException. However, if I call update before making changes, there is no error. I also tried using the original file as a template but it threw the same error. I included an abbreviated version of my code.
using FastExcel.FastExcel fastExcel = new FastExcel.FastExcel(new System.IO.FileInfo(excelPath));
var sheet = fastExcel.Read(1);
var rows = sheet.Rows.ToList();
for (int i = 1; i < rows.Count; i++)
{
if(rows[i].GetCellByColumnName("H").Value == "Change me") {
rows[i].GetCellByColumnName("G").Value = "Changed"
}
}
fastExcel.Update(sheet, 1); // errors here
Maybe I'm misunderstanding how the update works, but I'm hoping to get some clarity on this issue.
Full error message:
System.IO.IOException HResult=0x80131620 Message=Entries cannot be opened multiple times in Update mode. Source=System.IO.Compression StackTrace: at System.IO.Compression.ZipArchiveEntry.OpenInUpdateMode() at System.IO.Compression.ZipArchiveEntry.Open() at FastExcel.Worksheet.GetWorksheetPropertiesAndValidateNewName(FastExcel fastExcel, Nullable1 sheetNumber, String sheetName, String newSheetName) at FastExcel.Worksheet.GetWorksheetProperties(FastExcel fastExcel, Nullable1 sheetNumber, String sheetName) at FastExcel.Worksheet.Read(Nullable1 sheetNumber, String sheetName, Int32 existingHeadingRows) at FastExcel.FastExcel.Read(Nullable1 sheetNumber, String sheetName, Int32 existingHeadingRows) at FastExcel.FastExcel.Update(Worksheet data, Nullable`1 sheetNumber, String sheetName) at FastExcel.FastExcel.Update(Worksheet data, Int32 sheetNumber) at PopulateAllCells.Program.Main(String[] args) in
I have an existing excel file that I need to go through and change a cell value depending on the column values around it. Basically, I'm changing the cell values of 1 column. Everything works well until I get to update and then it throws a System.IO.IOException. However, if I call update before making changes, there is no error. I also tried using the original file as a template but it threw the same error. I included an abbreviated version of my code.
Maybe I'm misunderstanding how the update works, but I'm hoping to get some clarity on this issue. Full error message: System.IO.IOException HResult=0x80131620 Message=Entries cannot be opened multiple times in Update mode. Source=System.IO.Compression StackTrace: at System.IO.Compression.ZipArchiveEntry.OpenInUpdateMode() at System.IO.Compression.ZipArchiveEntry.Open() at FastExcel.Worksheet.GetWorksheetPropertiesAndValidateNewName(FastExcel fastExcel, Nullable
1 sheetNumber, String sheetName, String newSheetName) at FastExcel.Worksheet.GetWorksheetProperties(FastExcel fastExcel, Nullable
1 sheetNumber, String sheetName) at FastExcel.Worksheet.Read(Nullable1 sheetNumber, String sheetName, Int32 existingHeadingRows) at FastExcel.FastExcel.Read(Nullable
1 sheetNumber, String sheetName, Int32 existingHeadingRows) at FastExcel.FastExcel.Update(Worksheet data, Nullable`1 sheetNumber, String sheetName) at FastExcel.FastExcel.Update(Worksheet data, Int32 sheetNumber) at PopulateAllCells.Program.Main(String[] args) in