【Aspose.Cells.Net】Opening or saving a spreadsheet file for the first time takes much longer

I suspect that some automatic initialization work is being processed. Can these initializations be done manually? (For example, done in the background while displaying the splash window)

@Jason_Wang,

When loading or saving large or complex Excel files, the initial load time can be noticeable. This might be due to the overhead involved in initializing certain data structures and other settings by Aspose.Cells’ object model.

Additionally, the time cost can also be influenced by various factors such as the size and complexity of the spreadsheet, the number of worksheets and cells, the presence of formulas, images, or other embedded objects, and the overall system resources available, etc. Optimizing these factors can contribute to faster load or save times.

If you still think there is significant delay after enhancing the resources, kindly do provide sample (runnable) code and sample files (please zip the files first) to reproduce the issue, we will check it soon.

Hi, this is my code and test xlsx file (almost blank). I am running on windows+.Net60+Aspose.Cells.23.11

string path = @“your-path”;

Stopwatch sw = Stopwatch.StartNew();
Workbook workbook1 = new Workbook(path + “Test1.xlsx”);
Console.WriteLine(sw.ElapsedMilliseconds.ToString());

sw.Reset();
Workbook workbook2 = new Workbook(path + “Test2.xlsx”);
Console.WriteLine(sw.ElapsedMilliseconds.ToString());

sw.Reset();
Workbook workbook3 = new Workbook(path + “Test3.xlsx”);
Console.WriteLine(sw.ElapsedMilliseconds.ToString());

Console.ReadKey();

result is:
923
0
0

TestData.zip (17.1 KB)

@Jason_Wang
This phenomenon should be caused by time consumption during VS loading and running. If you are calling the Reset method before the Cells API, and you will get the same value.
The sample code as follows:

Console.WriteLine("version: " + CellsHelper.GetVersion());

Stopwatch sw = Stopwatch.StartNew();
sw.Reset();
Workbook workbook1 = new Workbook(filePath + "Test1.xlsx");
Console.WriteLine(sw.ElapsedMilliseconds.ToString());

sw.Reset();
Workbook workbook2 = new Workbook(filePath + "Test2.xlsx");
Console.WriteLine(sw.ElapsedMilliseconds.ToString());

sw.Reset();
Workbook workbook3 = new Workbook(filePath + "Test3.xlsx");
Console.WriteLine(sw.ElapsedMilliseconds.ToString());

Console.ReadKey();

The output:
version: 24.1
0
0
0

Hope helps a bit.

I am sorry, sw.Reset() is wrong, should be sw.Restart()

Console.WriteLine("version: " + CellsHelper.GetVersion());

Stopwatch sw = Stopwatch.StartNew();
sw.Restart();
Workbook workbook1 = new Workbook(filePath + “Test1.xlsx”);
Console.WriteLine(sw.ElapsedMilliseconds.ToString());

sw.Restart();
Workbook workbook2 = new Workbook(filePath + “Test2.xlsx”);
Console.WriteLine(sw.ElapsedMilliseconds.ToString());

sw.Restart();
Workbook workbook3 = new Workbook(filePath + “Test3.xlsx”);
Console.WriteLine(sw.ElapsedMilliseconds.ToString());

Console.ReadKey();

The output:
version: 23.11
970
3
9

@Jason_Wang,

I noticed the issue/behavior as you mentioned by using the code snippet. I found when opening a spreadsheet file for the first time by Aspose.Cells, it takes a bit longer than later traversing of other files. We need to evaluate if it is normal with the API, with Stopwatch API itself or related to GC or something else.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSNET-55025

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

1 Like

@Jason_Wang
1,The program code written in C # is also first compiled into a special type of bytecode through the C # compiler, Microsoft Intermediate Language (MSIL), and then compiled into machine code through a specific compiler (JIT compiler, Just In tIME, JITer) at runtime for the operating system to execute.
2,Some static class objects should be created when first init.

So you can call once when loading dll.

It seems very reasonable. I think I can open and save an empty Excel file at the appropriate time to solve this problem. Thank you for your response.

@Jason_Wang,

You are welcome. If you have any further queries or comments, please feel free to write back to us.