Strange behavior in Workbook.Save

We are facing a very strange behavior in function and hopefully you could give some hint.

We used to use Apspse.Cell to open a workbook and save it to stream using Workbook.Save() function, it works fine for EXCEL2003 / .NET 3.5, it also works fine for saving ot to EXCEL2007 format under .NET 3.5. However, recently we upgraded to .NET 4.0 and it turns out saving workbook to EXCEL 2007 takes much more time then saving it to 2003. Though the workbook is actually smaller in 2007. What possibly could cause the difference?

Another interesting finding is, this slowness only happens if we host this application in IIS. When we debug this function in Visual Studio Development Server (Cassani), it’s again much faster. We cannot think of any difference between IIS and Cassani would cause the difference in performance. Any thought?

Much appreciated for any help!


That looks very strange to us. Please try the attached latest version/fix v5.2.1.2.

If you still find the issue, please create a separate sample Asp.NET IIS based Application, zip it and post it here to show the issue, we will check your issue soon.

Thank you.

unfortunately the latest version doesn’t help and we could not release the workbook to external party. Could you suggest if there’s any way I could debug or trace to see what actually causing the difference?

I am afraid, we have no clue why it is taking much time as you mentioned. Here the Workbook.Save() works fine whether we use it in Asp.NET(IIS based) or in windows forms.

Please create a simple project, zip it and post it here, we can check your issue.

Thank you.

Some more info, I used the dotTrace to trace the two applications and both bottleneck happens in System.Text.StringBuilder.Remove within Aspose.Cells.Cell.Get_xxx() method.

The difference is in Development Server, it’s much more efficient than IIS. Any lucks here?


Could you conduct a test using my attached version v5.2.1.x in my previous post. You may comment our the licensing code to just for testing and let us know about it.

We will also try to look into it on our end.

Thank you.

Here's a simple website application using the latest Aspose.Cell to process a 2007 workbook. Hope you could use this to trace the problem.

Please make the necessary change to the actual file location in your test environment.

Note that if you comment the wb.Save(ms, SaveFormat.Xlsx) and change it to wb.SaveToStream(), it's much faster.


Thanks for the sample file with project.

I have tested it with your
template Xlsx file, it takes lots of time to save the
workbook to memory stream for Xlsx format. When using the method Workbook.SaveToStream, it takes very less
time. I have also conducted test of your code with your file on WinForm, it works fine on it. So, the problem is on Asp.NET platform with your specific Excel 2007 file as I have tested other Excel 2007 files in your project, it works fine.

I have logged your issue with an id:
CELLSNET-23122. We will look into your issue and get back to you soon.

Thank you.


After further investigation:
a) For wb.Save(ms, SaveFormat.Xlsx);
As you known, Xlsx is a zip file format which contains several xml file. We found it took long time in saving xml file to zip file format. So, it is quite possible that we cannot improve it very soon. We will continue to look into it. Once we have any update, we will let you know.

b) For wb.SaveToStream();
the method will save the workbook as xls file, XLS is simple as compared to XLSX, so it takes very less time.

Thank you.

Any suggestion why it works in Winform or VS development server?

Hi yuwei24,

We have fixed this issue. Please download the Aspose.Cells for .NET

Great it works, just being curious, what's the root cause and changes you've made here.


<!–[if gte mso 10]> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;}



We tested and we found it works fine in Net2.0, but it works slowly in Net4.0 as we noticed. After comparing net2.0 and net4.0, we found StringBuilder class was rebuilt in net4.0 and it was the issue of working slowly. We have modified the usage of StringBuilder in the latest fix to make it work fine in net4.0 and net2.0.

Kindly do try and let us know if it works fine now.

Hi, this works great in the test application but when we put it into the original application, we see this error message, could you advise?

" The subscription included in this license allows free upgrades until 30 Dec 2010, but this version of the product was released on 25 Jan 2011. Please renew the subscription or use a previous version of the product."


Well, since your license subscription allows you only to use Aspose.Cells versions/fixes that were released before December 30, 2010(you license expiry date), so you cannot use your license with the latest fix v5.2.2.1 etc. You need to upgrade your subscription to use the latest versions/fixes of the product. Please post a query to Aspose.Purchase forum:

Thank you.

The issues you have found earlier (filed as 23122) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.