Back to Devexpress

IWorkbook.Calculate() Method

officefileapi-devexpress-dot-spreadsheet-dot-iworkbook-bf1052ff.md

latest7.6 KB
Original Source

IWorkbook.Calculate() Method

Forces recalculation of the workbook.

Namespace : DevExpress.Spreadsheet

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
void Calculate()
vb
Sub Calculate

Remarks

The Calculate recalculates values in cells marked for calculation. The cell is marked for calculation by the Spreadsheet control if any change is made to its formula, or when a cell range, referenced in the formula, changes.

There are also “CalculateAlways” cells which are always marked as needing recalculation. The Calculate method calculates them as well. “CalculateAlways” cell is the cell for which any of the following statements is true:

  • the cell contains a volatile function (IFunction.Volatile)
  • the cell references another “CalculateAlways” cell
  • the cell contains a circular reference

Tip

You can create a custom calculation service implementing the ICustomCalculationService interface to change the way cells are calculated.

Tip

When the Calculate is called, all workbook modifications are applied and all cells are calculated. Recalculation of the entire workbook can take a significant amount of time and resources. To calculate only a formula contained in a single cell, use the IWorkbook.Evaluate method.

Note

This method works only if the CalculationOptions.Mode setting is CalculationMode.Manual.

The following code snippets (auto-collected from DevExpress Examples) contain references to the Calculate() method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-spreadsheet-apply-conditional-formatting-to-a-range-of-cells/CS/SpreadsheetControl/SpreadsheetActions/ConditionalFormatting.cs#L29

csharp
{
    workbook.Calculate();
    workbook.BeginUpdate();

spreadsheet-document-api-apply-conditional-formatting-to-cell-range/CS/ConditionalFormatting_Example/SpreadsheetActions/ConditionalFormatting.cs#L31

csharp
{
    workbook.Calculate();
    workbook.BeginUpdate();

wpf-spreadsheet-how-to-apply-conditional-formatting-to-a-range-of-cells/CS/ConditionalFormatting_WPF_Examples/SpreadsheetActions/ConditionalFormatting.cs#L28

csharp
{
    workbook.Calculate();
    workbook.BeginUpdate();

winforms-spreadsheetcontrol-api-part-2/CS/SpreadsheetControl_API_Part02/SpreadsheetActions/SearchActions.cs#L19

csharp
workbook.LoadDocument("Documents\\ExpenseReport.xlsx");
workbook.Calculate();
Worksheet worksheet = workbook.Worksheets[0];

wpf-spreadsheetcontrol-api-part-2/CS/SpreadsheetControl_WPF_API_Part02/SpreadsheetActions/SearchActions.cs#L21

csharp
workbook.LoadDocument("Documents\\ExpenseReport.xlsx");
workbook.Calculate();
Worksheet worksheet = workbook.Worksheets[0];

winforms-spreadsheet-apply-conditional-formatting-to-a-range-of-cells/VB/SpreadsheetControl/SpreadsheetActions/ConditionalFormatting.vb#L29

vb
Private Shared Sub AddAverageConditionalFormatting(ByVal workbook As IWorkbook)
    workbook.Calculate()
    workbook.BeginUpdate()

spreadsheet-document-api-apply-conditional-formatting-to-cell-range/VB/ConditionalFormatting_Example/SpreadsheetActions/ConditionalFormatting.vb#L37

vb
Private Shared Sub AddAverageConditionalFormatting(ByVal workbook As IWorkbook)
    workbook.Calculate()
    workbook.BeginUpdate()

wpf-spreadsheet-how-to-apply-conditional-formatting-to-a-range-of-cells/VB/ConditionalFormatting_WPF_Examples/SpreadsheetActions/ConditionalFormatting.vb#L27

vb
Private Shared Sub AddAverageConditionalFormatting(ByVal workbook As IWorkbook)
    workbook.Calculate()
    workbook.BeginUpdate()

winforms-spreadsheetcontrol-api-part-2/VB/SpreadsheetControl_API_Part02/SpreadsheetActions/SearchActions.vb#L16

vb
workbook.LoadDocument("Documents\ExpenseReport.xlsx")
workbook.Calculate()
Dim worksheet As Worksheet = workbook.Worksheets(0)

wpf-spreadsheetcontrol-api-part-2/VB/SpreadsheetControl_WPF_API_Part02/SpreadsheetActions/SearchActions.vb#L18

vb
workbook.LoadDocument("Documents\ExpenseReport.xlsx")
workbook.Calculate()
Dim worksheet As Worksheet = workbook.Worksheets(0)

See Also

Calculation Process

IWorkbook Interface

IWorkbook Members

DevExpress.Spreadsheet Namespace