Load multiple instances of a single file in memory

Hi,

Currently I’m implementing Aspose Cells in .NET application which uses an excel template for calculations. Once the web application is launched, at a button click event, the excel template is instantiated at run time and all specific data is written to it. Once this is complete, the calculated result values are read from it and displayed on the front end.

Since this application will be consumed by several users concurrently, how can we handle this in a multi user environment. The documentation provides some alternatives:

  1. Load 1 file and then create new instances per user

  2. Load 1 file, create 1 instance shared between users, (semaphores or synchronization necessary)

  3. Load 1 file, create pool of instances shared between users (10 instances synchronized and shared between users).

Could you illustrate each with an example, since the site does not have enough examples on this topic.

Thanks & Regards,

Swapna.

Hi Swapna,

Thanks for your posting and using Aspose.Cells.

In ASP.NET application, whenever your code relating to loading of workbook will be executed, it will load new instance of workbook.

For example, if you have written the following code in the Page_Load event, then whenever your page will be executed a new instance of workbook object will be created

C#


Workbook myWorkbook = new Workbook(filePath);


Now, if you want to use myWorkbook variable in other user's sessions, then you will have to save the variable in session scope. If you want to use it in application level, then you will have to save it in application scope.

You should read ASP.NET State Management to get the idea of how to use different States e.g (Cookies, View State, Session State, Application State etc)

  • ASP.NET State Management