Ways to Improve Performance
In This Topic
You can use the following methods to improve the performance of Spread Winforms control.
- When you do not want to display cell note (NoteStyle property of Cell object is set to something other than StickyNote), set the AutoUpdateNotes property of SheetView class to False. By doing so, this will prevent checks on cell note of the StickyNote type, which will allow you to change or move the display state.
- If you set the AllowCellOverflow property of the FpSpread class to enable, you can accelerate layout recalculation by disabling it. With this feature enabled, a large amount of text width calculation is performed each time cell data changes.
- When using a formula, set the SheetView class's AutoCalculation property to False, update the sheet, set it back to True, and call the Recalculate method.You can eliminate the redundant intermediate process of recalculating formulas each time you update.
- Since layout objects calculate only the visible part of the sheet, you can improve performance by reducing the control size or reducing the number of columns and rows displayed at one time.
- It is also effective to implement custom sheet model object (such as custom data model object that implements the ISheetDataModel interface) with unnecessary feature removed. For example, if you do not need the data binding feature, you do not need to implement the data binding interface.
Improve Performance Using CacheOptions
The performance of following formula functions can be improved with exact match.
The CacheOptions enumeration in CalculationEngine class can be used to define the type of caching while using these functions:
- On: (default) Caching is used. Cached data has short life in memory.
- Aggressive: Caching is used as much as possible. Cached data has a longer life in memory.
- None: No caching is used.
The performance is improved in the following order:
Aggressive > On > None
The following example applies Aggressive CacheOptions option and records the time taken to load the imported Excel file.
C# |
Copy Code
|
fpSpread1.AsWorkbook().WorkbookSet.CalculationEngine.CacheOptions = CacheOptions.Aggressive;
// Sample Excel file containing XMATCH function
fpSpread1.OpenExcel("bigTable - XMatch.xlsx");
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
// We check the performance by measuring the time to invoke Calculate only
fpSpread1.AsWorkbook().WorkbookSet.CalculationEngine.Calculate(fpSpread1.AsWorkbook(), true);
stopwatch.Stop();
long miliseconds = stopwatch.ElapsedMilliseconds;
listBox1.Items.Add(miliseconds.ToString());
|