You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 9, 2020. It is now read-only.
I am trying to read and update an xlsx file which contain escape character "&". But sharedStrings.xml is corrupted after saving(as) the file. I also tried to write the data into a new file and it worked. Error.XLSX Pass.XLSX Test.xlsx
Here is the code:
public void TestEscapgeCharater()
{
string srcPath = "Test.XLSX";
string errPath = "Error.XLSX";
string passPath = "Pass.XLSX";
using (ExcelPackage package = new ExcelPackage(new System.IO.FileInfo(srcPath)))
{
string addr = package.Workbook.Worksheets[1].Dimension.Address;
object[,] objArr = (object[,])package.Workbook.Worksheets[1].Cells[addr].Value;
//update some cells here
//Error
package.Workbook.Worksheets[1].Cells[addr].Value = objArr;
package.SaveAs(new System.IO.FileInfo(errPath));
//Pass
using (ExcelPackage new_package = new ExcelPackage(new System.IO.FileInfo(passPath)))
{
new_package.Workbook.Worksheets.Add(package.Workbook.Worksheets[1].Name);
new_package.Workbook.Worksheets[1].Cells[addr].Value = objArr;
new_package.Save();
}
}
}
The text was updated successfully, but these errors were encountered:
I found the issue. When the sharedString is richtext, this lib does not change inner text to xml format.
Here is the source code from SaveSharedStringHandler in ExcelWorkbook.cs
Hi JanKallMan,
I am trying to read and update an xlsx file which contain escape character "&". But sharedStrings.xml is corrupted after saving(as) the file. I also tried to write the data into a new file and it worked.
Error.XLSX
Pass.XLSX
Test.xlsx
Here is the code:
The text was updated successfully, but these errors were encountered: