How to stop automatic calculation in Spreadsheet
Description
This Knowledge base explains about how to stop automatic calculation in Spreadsheet.
Solution
In Spreadsheet, the formulas are recalculated automatically whenever the value in the dependent cells are changed in each sheet. Setting calculation option to ‘manual’ prevents the recalculation of formula while changing its dependent cell.
HTML
<div id="Spreadsheet"></div>
JS
$(function () { $("#Spreadsheet").ejSpreadsheet({ sheets: [{ rows: [{ cells: [{ value: 1 }] }, { cells: [{ value: 2 }] }, { cells: [{ value: "=SUM(A1,A2)" }] }] }], loadComplete: "onLoadComplete" }); });
RAZOR
@(Html.EJ().Spreadsheet<object>("Spreadsheet") .Sheets(sheet => { sheet.Rows(rows => { rows.Cells(cells => { cells.Value("1").Add(); }).Add(); rows.Cells(cells => { cells.Value("2").Add(); }).Add(); rows.Cells(cells => { cells.Value("=SUM(A1,A2)").Add(); }).Add(); }).Add(); }) .ClientSideEvents( events => events.LoadComplete("onLoadComplete") ) )
ASPX
<ej:spreadsheet id="Spreadsheet1" runat="server"> <Sheets> <ej:Sheet> <Rows> <ej:Row> <Cells> <ej:Cell Value="1"> </ej:Cell> </Cells> </ej:Row> <ej:Row> <Cells> <ej:Cell Value="2"> </ej:Cell> </Cells> </ej:Row> <ej:Row> <Cells> <ej:Cell Value="=SUM(A1,A2)"> </ej:Cell> </Cells> </ej:Row> </Rows> </ej:Sheet> </Sheets> <ClientSideEvents LoadComplete="onLoadComplete" /> </ej:spreadsheet>
function onLoadComplete(args) { if (!this.isImport) { //Suspending automatic calculation by passing false in isAutomatic parameter this.XLEdit.calcOption(false); //Updating Cell A1 value this.XLEdit.updateCellValue({ rowIndex: 0, colIndex: 0 }, "4"); } } |
The following screenshots displays the Spreadsheet after rendering it with above code snippet
Figure: Spreadsheet after setting manual calculation option.
Once you have changed the calculate options in Spreadsheet to Manual, you can calculate the formula in specific sheet or all the sheets using ‘calcNow()’ method.