admin管理员组文章数量:1279016
I have a .NET Framework 4.8, C# application. I'm using IronXL.Excel 2025.2.5 to read and export data to an xls file (that's an old Excel 97-2003 file; unfortunately this cannot be changed to a modern Excel version; I have no control over this). I set up a very short test script to read the file, make a change and save it. It worked fine. However, when I then open the file I get the error "We found a problem..." (see full error below). It still allows me to open the file and if I save it, the error goes away. However, this error is going to cause confusion with my client. Is there anyway to save the changes without getting this error message?
I've tried other nuget packages like ClosedXML and EPPlus, but none of them seemed to work with xls files. If you have a suggestion that will let me read and write to an xls file, I'm open to using another package.
Here is my code:
string filePath = @"C:\TEMP\Test.xls";
WorkBook workBook = WorkBook.Load(filePath);
WorkSheet worksheet = workBook.WorkSheets[0];
for (int row = 1; row < 10000; row++)
{
string cell = $@"A{row}";
string cellValue = worksheet[cell].ToString();
if (cellValue == "")
{
worksheet[cell].Value = "New Value Here";
}
}
workBook.Save();
Here is the error message:
本文标签: cHow do I prevent IronXL from corrupting my saved Excel fileStack Overflow
版权声明:本文标题:c# - How do I prevent IronXL from corrupting my saved Excel file? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741240884a2363952.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论