Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Tue Dec 05, 2023 1:08 pm

Hello,

I try to fill in my Excel file, but when I open it after processing, Excel tells me that it's corrupt.

On investigating, it turns out that the cause lies in the calculation of a formula pointing to an Excel sheet with an apostrophe in its name.
If I try again and remove the apostrophe from the name, the Excel file is not corrupted.
When I open the corrupted sheet in XML format, I notice that the formula has been modified. Spire.XLS deletes the apostrophe, which corrupts the formula and therefore the Excel file.

Before:
Code: Select all
IF('Input Histo'!A1>'L''Escale price & net worths'!A1,'Input Histo'!A1,'L''Escale price & net worths'!A1)


After:
Code: Select all
IF('Input Histo'!A1>'L'Escale price & net worths'!A1,'Input Histo'!A1,'L'Escale price & net worths'!A1)


I can't change the names of the sheets because I'm just injecting the data.
Here's a simplified example of the C# code simulating a fill with fictitious data.

Code: Select all
 using Workbook wb = new();
 wb.LoadFromFile(Environment.CurrentDirectory + "\\Price following - Example.xlsx");
 DataTable dt = new();
 for (int i = 0; i < 15; i++)
 {
  dt.Columns.Add();
  for (int y = 0; y < 30; y++)
  {
   dt.Rows.Add();
   dt.Rows[y][i] = new Random().Next();
  }
 }
 for (int i = 0; i < dt.Columns.Count; i++)
 {
  for (int j = 0; j < dt.Rows.Count; j++)
  {
   string currentCell = string.Concat(GetColumnLetter(i + 1), j + 1);
   using CellRange cell = wb.Worksheets[0].Range[currentCell];
   cell.Text = Convert.ToString(dt.Rows[j].ItemArray[i]);
  }
 }
 wb.CalculateAllValue();
 wb.Save();


Attached is a fictitious example of the Excel file before and after filling.

I'm currently using the latest version available (13.11.4).

Thanks in advanced
Attachments
corruptedExample.zip
Excel file before & after filling
(42.89 KiB) Downloaded 541 times

Pierre.toker
 
Posts: 2
Joined: Tue Dec 05, 2023 12:24 pm

Wed Dec 06, 2023 5:33 am

Hi,

Thank you for your inquiry.
I have tested the file and code you provided and reproduced your issue. I have recorded this issue in our bug tracking system with the number "SPIREXLS-5022". Our development team will investigate and fix it in the future. If this issue is resolved, we will notify you as soon as possible. We deeply apologize for any inconvenience caused.

Sincerely,
Ula
E-iceblue support team
User avatar

Ula.wang
 
Posts: 282
Joined: Mon Aug 07, 2023 1:38 am

Mon Jan 08, 2024 1:52 am

Hi,

Thank you for your patience.
I'm glad to inform you that we just released Spire.XLS for .Net 14.1 has resolved your issue with SPIREXLS-5022. Welcome to download the test.

Website download link: https://www.e-iceblue.com/Download/download-excel-for-net-now.html
Nuget link:https://www.nuget.org/packages/Spire.XLS/14.1.0

Sincerely,
Ula
E-iceblue support team
User avatar

Ula.wang
 
Posts: 282
Joined: Mon Aug 07, 2023 1:38 am

Thu Jan 11, 2024 1:56 pm

Hello,

I can confirm that the bug has been fixed.

Thank you.

Pierre.toker
 
Posts: 2
Joined: Tue Dec 05, 2023 12:24 pm

Fri Jan 12, 2024 1:20 am

Hello,

Glad to hear that.
If you encounter other issues related to our products in the future, please feel free to contact us.
Have a nice day.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.XLS