# Setting the Calculation Mode for a Workbook

## Content



The [CalculationMode](/componentone/api/wpf/online-excel/dotnet-framework-api/C1.WPF.Excel.4.6.2/C1.WPF.Excel.C1XLBook.CalculationMode.html) property specifies the calculation mode for all formulas in the workbook. The [CalculationMode](/componentone/api/wpf/online-excel/dotnet-framework-api/C1.WPF.Excel.4.6.2/C1.WPF.Excel.CalculationMode.html) enumeration provides three options: **Manual** (you manually perform the calculation), **Auto** (the calculation is automatically performed), or **AutoNoTable** (the calculation is performed except on tables).

To set the calculation mode, follow these steps:

1.  Add a reference to C1.WPF.Excel.dll or C1.Silverlight.Excel.dll and create a **C1XLBook**.
    
    ```csharp
    // Create a new workbook
    C1XLBook book = new C1XLBook();
    ```
    
2.  Add a simple formula using the following code:
    
    ```csharp
    XLSheet sheet = book.Sheets[0];
    // simple formula
      sheet[7, 0].Value = "Formula: 5!";
      sheet[7, 1].Value = 122;
      sheet[7, 1].Formula = "1*2*3*4*5";
      book.CalculationMode = CalculationMode.Auto;
    ```
    
3.  Save and open the .xlsx file.
    
    ```csharp
    // Save and open the file
    book.Save(@"C:\test.xlsx");
    System.Diagnostics.Process.Start(@"C:\test.xlsx");
    ```
    
    Notice that the value for the cell in (7,1) is **120**, or the total of **1\*2\*3\*4\*5**, not **122**, since we set the **CalculationMode** to **Auto**.
    
    ![](https://cdn.mescius.io/document-site-files/images/4e8fb55a-cee4-4e5b-a6f1-f4ba4ccbfde1/c1excel_graphics/image11_10.png)