We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Improving performance by caching workbooks


We are building an ASP.NET solution, where we use 5 different Excel templates (designers) to create Excel reports based on user selection.

The process is this:

1. Load the appropriate template from the disk

2. Based on user selection, add data to the template

3. Save the document on disk (for auditing purposes we need to save the document, not just return it)

4. Return a URL to the document.

Aspose is really fast when it comes to modifying a workbook that has been loaded. However, loading the template takes a "considerable" time, in percentage of the entire workflow this counts for 20-50% depending on the size of the template.

Therefore, we are considering caching the templates (there are only 5 of them, so memory pressure will not be a problem). We will use file notification on the template folder to invalidate the cache when any of the template changes.

Can you give some advice on if this is supported and appropriate? And how would we implement this?

The most obvious way would be to keep a Dictionary which holds references to the loaded workbooks. When a new report is to be created, we would retrieve the workbook from the dictionary, based on the path (loading it if it doesn't exist) and then call Workbook.Copy to create a new instance of the template. This new instance would than be populated with data, saved to disk, etc. In other words, multiple threads may creates copies of the same instance, but manipulating would be single-threaded.

The code that retrieves (and optionally loads a new template) instances from the dictionary would have to be synchronized.

Would this work and be thread-safe? Any comments on the topic is highly appreciated.




Thanks for your posting.

Our development team will look into your requirements and after review them will advise you asap.

This issue has been logged in our database as CELLSNET-40170.

Hi Fredik,

Aspose.Cells is thread-safe,so your solution can work fine.