Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Document-Processing-toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -5432,6 +5432,7 @@
<li><a href="/document-processing/excel/spreadsheet/asp-net-core/ribbon">Ribbon</a></li>
<li><a href="/document-processing/excel/spreadsheet/asp-net-core/print">Print</a></li>
<li><a href="/document-processing/excel/spreadsheet/asp-net-core/performance-best-practices">Performance Best Practices</a></li>
<li><a href="/document-processing/excel/spreadsheet/asp-net-core/batch-update">Batch Update</a></li>
<li><a href="/document-processing/excel/spreadsheet/asp-net-core/global-local">Globalization</a></li>
<li><a href="/document-processing/excel/spreadsheet/asp-net-core/accessibility">Accessibility</a></li>
<li><a href="/document-processing/excel/spreadsheet/asp-net-core/keyboard-shortcuts">Keyboard Shortcuts</a></li>
Expand Down Expand Up @@ -5481,6 +5482,7 @@
<li><a href="/document-processing/excel/spreadsheet/asp-net-mvc/ribbon">Ribbon</a></li>
<li><a href="/document-processing/excel/spreadsheet/asp-net-mvc/print">Print</a></li>
<li><a href="/document-processing/excel/spreadsheet/asp-net-mvc/performance-best-practices">Performance Best Practices</a></li>
<li><a href="/document-processing/excel/spreadsheet/asp-net-mvc/batch-update">Batch Update</a></li>
<li><a href="/document-processing/excel/spreadsheet/asp-net-mvc/global-local">Globalization</a></li>
<li><a href="/document-processing/excel/spreadsheet/asp-net-mvc/accessibility">Accessibility</a></li>
<li><a href="/document-processing/excel/spreadsheet/asp-net-mvc/keyboard-shortcuts">Keyboard Shortcuts</a></li>
Expand Down Expand Up @@ -5534,6 +5536,7 @@
<li><a href="/document-processing/excel/spreadsheet/angular/styles">Styles and Appearance</a></li>
<li><a href="/document-processing/excel/spreadsheet/angular/print">Print</a></li>
<li><a href="/document-processing/excel/spreadsheet/angular/performance-best-practices">Performance Best Practices</a></li>
<li><a href="/document-processing/excel/spreadsheet/angular/batch-update">Batch Update</a></li>
<li><a href="/document-processing/excel/spreadsheet/angular/performance-metrics">Performance Metrics</a></li>
<li><a href="/document-processing/excel/spreadsheet/angular/global-local">Globalization</a></li>
<li><a href="/document-processing/excel/spreadsheet/angular/accessibility">Accessibility</a></li>
Expand Down Expand Up @@ -5727,6 +5730,7 @@
<li><a href="/document-processing/excel/spreadsheet/vue/ribbon">Ribbon</a></li>
<li><a href="/document-processing/excel/spreadsheet/vue/print">Print</a></li>
<li><a href="/document-processing/excel/spreadsheet/vue/performance-best-practices">Performance Best Practices</a></li>
<li><a href="/document-processing/excel/spreadsheet/vue/batch-update">Batch Update</a></li>
<li><a href="/document-processing/excel/spreadsheet/vue/global-local">Globalization</a></li>
<li><a href="/document-processing/excel/spreadsheet/vue/accessibility">Accessibility</a></li>
<li><a href="/document-processing/excel/spreadsheet/vue/keyboard-shortcuts">Keyboard Shortcuts</a>
Expand Down Expand Up @@ -5776,6 +5780,7 @@
<li><a href="/document-processing/excel/spreadsheet/javascript-es5/styles">Styles and Appearance</a></li>
<li><a href="/document-processing/excel/spreadsheet/javascript-es5/print">Print</a></li>
<li><a href="/document-processing/excel/spreadsheet/javascript-es5/performance-best-practices">Performance Best Practices</a></li>
<li><a href="/document-processing/excel/spreadsheet/Javascript-es5/batch-update">Batch Update</a></li>
<li><a href="/document-processing/excel/spreadsheet/javascript-es5/global-local">Globalization</a></li>
<li><a href="/document-processing/excel/spreadsheet/javascript-es5/accessibility">Accessibility</a></li>
<li><a href="/document-processing/excel/spreadsheet/javascript-es5/keyboard-shortcuts">Keyboard Shortcuts</a></li>
Expand Down Expand Up @@ -5822,6 +5827,7 @@
<li><a href="/document-processing/excel/spreadsheet/javascript-es6/styles">Styles and Appearance</a></li>
<li><a href="/document-processing/excel/spreadsheet/javascript-es6/print">Print</a></li>
<li><a href="/document-processing/excel/spreadsheet/javascript-es6/performance-best-practices">Performance Best Practices</a></li>
<li><a href="/document-processing/excel/spreadsheet/Javascript-es6/batch-update">Batch Update</a></li>
<li><a href="/document-processing/excel/spreadsheet/javascript-es6/performance-metrics">Performance Metrics</a></li>
<li><a href="/document-processing/excel/spreadsheet/javascript-es6/global-local">Globalization</a></li>
<li><a href="/document-processing/excel/spreadsheet/javascript-es6/accessibility">Accessibility</a></li>
Expand Down
144 changes: 144 additions & 0 deletions Document-Processing/Excel/Spreadsheet/ASP-NET-CORE/batch-update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
---
layout: post
title: Batch Update in ASP.NET Core Spreadsheet component | Syncfusion
description: Improve performance in Syncfusion ASP.NET Core Spreadsheet by using suspendRefresh and resumeRefresh to batch multiple updates and avoid repeated rendering.
platform: document-processing
control: Spreadsheet
documentation: ug
---

# Batch Update in ASP.NET Core Spreadsheet

The Spreadsheet refreshes its UI after each operation performed through public methods, such as updating a cell, applying formatting, or inserting rows. This immediate rendering works well for a few actions, but it can lead to performance issues when many operations are executed one after another.

The **batch update** feature lets you temporarily pause UI rendering, perform multiple operations, and then refresh the UI only once at the end. This helps reduce unnecessary re-rendering and improves the overall performance of bulk updates.

This is especially useful when the Spreadsheet is updated programmatically during initialization, data processing, or large-scale scenarios.

## When to use batch update

Use batch update when you need to perform several actions in sequence, such as:

- Updating many cells at once
- Applying formatting to a large range
- Inserting or deleting multiple rows or columns
- Running repeated operations inside a loop
- Working with large datasets

For a few operations, batch update is usually not required.

## How to use batch update

Batch update is performed with two methods:

- `suspendRefresh()` — pauses UI rendering
- `resumeRefresh()` — applies all pending visual updates

### Step 1: Suspend UI refresh

Call `suspendRefresh()` before starting multiple Spreadsheet operations.

### Step 2: Perform the required operations

Execute the actions you want to apply. The Spreadsheet model is updated, but the UI is not refreshed after each call.

### Step 3: Resume UI refresh

Call `resumeRefresh()` after all operations are complete. The Spreadsheet then renders all accumulated changes in a single refresh.

### Pattern for batch update

```js
let spreadsheet;

function created() {
spreadsheet.suspendRefresh();
spreadsheet.insertRow(0, 0);
spreadsheet.updateCell({ value: 'Project Budget Tracker - Q2 2026' }, 'A1');
spreadsheet.merge('A1:K1');
spreadsheet.updateCell({ value: 'Reference' }, 'K2');
spreadsheet.updateCell({ value: 'Total Budget' }, 'A13');
spreadsheet.updateCell({ formula: '=SUM(F3:F12)' }, 'F13');
spreadsheet.updateCell({ formula: '=SUM(G3:G12)' }, 'G13');
spreadsheet.updateCell({ formula: '=SUM(H3:H12)' }, 'H13');
spreadsheet.addHyperlink('https://help.syncfusion.com/document-processing/excel/spreadsheet/asp-net-core/overview', 'K3:K12', 'Open Guide');
spreadsheet.cellFormat({ fontWeight: 'bold', fontSize: '14pt', textAlign: 'center', verticalAlign: 'middle', backgroundColor: '#4472C4', color: '#FFFFFF' }, 'A1:K1');
spreadsheet.cellFormat({ fontWeight: 'bold', textAlign: 'center', backgroundColor: '#EAEAEA' }, 'A2:K2');
spreadsheet.numberFormat('$#,##0.00', 'F3:H13');
spreadsheet.addDataValidation({ type: 'WholeNumber', operator: 'Between', value1: '1', value2: '5', isHighlighted: true }, 'J3:J12');
spreadsheet.wrap('A3:A12', true);
spreadsheet.setBorder({ border: '1px solid #C8C8C8' }, 'A2:K13', 'Outer');
spreadsheet.setRowHeight(50, 0);
spreadsheet.setRowsHeight(30, ['1:13']);
spreadsheet.setColWidth(220, 0);
spreadsheet.setColumnsWidth(90, ['B:K']);
spreadsheet.resumeRefresh();
}
```

## API reference

### suspendRefresh()

Suspends visual updates in the Spreadsheet.

#### Behavior

- Prevents the UI from refreshing after each operation
- Allows multiple actions to be grouped together
- Keeps internal model updates running
- Must be paired with `resumeRefresh()`

### resumeRefresh()

Resumes visual updates and applies all pending changes.

#### Behavior

- Applies all operations performed after `suspendRefresh()`
- Refreshes the Spreadsheet UI once
- Improves rendering efficiency for bulk operations

## Code example

{% tabs %}
{% highlight cshtml tabtitle="CSHTML" %}
{% include code-snippet/spreadsheet/asp-net-core/batch-update-cs1/tagHelper %}
{% endhighlight %}
{% highlight c# tabtitle="BatchUpdate.cs" %}
{% include code-snippet/spreadsheet/asp-net-core/batch-update-cs1/batchupdate.cs %}
{% endhighlight %}
{% endtabs %}

## Common operations supported in batch update

The following types of operations can be performed between `suspendRefresh()` and `resumeRefresh()`:

- **Cell operations:** `updateCell`, `autoFill`, `clear`
- **Row and column operations:** `insertRow`, `insertColumn`, `hideRow`, `hideColumn`, `setRowsHeight`, `setRowHeight`, `setColWidth`, `setColumnsWidth`, `autoFit`
- **Formatting:** `cellFormat`, `numberFormat`, `wrap`, `setBorder`
- **Merge operations:** `merge`, `unMerge`
- **Hyperlinks:** `addHyperlink`, `removeHyperlink`
- **Data validation:** `addDataValidation`, `removeDataValidation`, `addInvalidHighlight`, `removeInvalidHighlight`
- **Conditional formatting:** `conditionalFormat`, `clearConditionalFormat`
- **Sheet operations:** `insertSheet`, `duplicateSheet`, `moveSheet`, `delete`
- **Protection:** `protectSheet`, `unProtectSheet`
- **Freeze panes:** `freezePanes`, `unfreezePanes`
- **Clipboard operations:** `cut`, `copy`, `paste`
- **Editing and navigation:** `find`, `replace`, `selectRange`, `goTo`
- **Charts:** `insertChart`, `deleteChart`
- **Images:** `insertImage`, `deleteImage`
- **Filtering:** `applyFilter`, `clearFilter`
- **Other actions:** `sort`, `calculateNow`, `addDefinedName`, `updateRange`

## Notes

- Use batch update only when multiple operations are executed together
- Avoid using it for few, simple actions
- It is most useful for initialization logic and programmatic bulk updates
- Data and model changes are processed during the suspended state; only visual refresh is delayed

## See Also

* [Data Binding](https://help.syncfusion.com/document-processing/excel/spreadsheet/asp-net-core/data-binding)
* [Worksheet](https://help.syncfusion.com/document-processing/excel/spreadsheet/asp-net-core/worksheet)
143 changes: 143 additions & 0 deletions Document-Processing/Excel/Spreadsheet/ASP-NET-MVC/batch-update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
---
layout: post
title: Batch Update in ASP.NET MVC Spreadsheet component | Syncfusion
description: Improve performance in Syncfusion ASP.NET MVC Spreadsheet by using suspendRefresh and resumeRefresh to batch multiple updates and avoid repeated rendering.
platform: document-processing
control: Spreadsheet
documentation: ug
---

# Batch Update in ASP.NET MVC Spreadsheet

The Spreadsheet refreshes its UI after each operation performed through public methods, such as updating a cell, applying formatting, or inserting rows. This immediate rendering works well for a few actions, but it can lead to performance issues when many operations are executed one after another.

The **batch update** feature lets you temporarily pause UI rendering, perform multiple operations, and then refresh the UI only once at the end. This helps reduce unnecessary re-rendering and improves the overall performance of bulk updates.

This is especially useful when the Spreadsheet is updated programmatically during initialization, data processing, or large-scale scenarios.

## When to use batch update

Use batch update when you need to perform several actions in sequence, such as:

- Updating many cells at once
- Applying formatting to a large range
- Inserting or deleting multiple rows or columns
- Running repeated operations inside a loop
- Working with large datasets

For a few operations, batch update is usually not required.

## How to use batch update

Batch update is performed with two methods:

- `suspendRefresh()` — pauses UI rendering
- `resumeRefresh()` — applies all pending visual updates

### Step 1: Suspend UI refresh

Call `suspendRefresh()` before starting multiple Spreadsheet operations.

### Step 2: Perform the required operations

Execute the actions you want to apply. The Spreadsheet model is updated, but the UI is not refreshed after each call.

### Step 3: Resume UI refresh

Call `resumeRefresh()` after all operations are complete. The Spreadsheet then renders all accumulated changes in a single refresh.

### Pattern for batch update

```js
function created() {
var spreadsheetObj = ej.base.getComponent(document.getElementById('spreadsheet'), 'spreadsheet');
spreadsheetObj.suspendRefresh();
spreadsheetObj.insertRow(0, 0);
spreadsheetObj.updateCell({ value: 'Project Budget Tracker - Q2 2026' }, 'A1');
spreadsheetObj.merge('A1:K1');
spreadsheetObj.updateCell({ value: 'Reference' }, 'K2');
spreadsheetObj.updateCell({ value: 'Total Budget' }, 'A13');
spreadsheetObj.updateCell({ formula: '=SUM(F3:F12)' }, 'F13');
spreadsheetObj.updateCell({ formula: '=SUM(G3:G12)' }, 'G13');
spreadsheetObj.updateCell({ formula: '=SUM(H3:H12)' }, 'H13');
spreadsheetObj.addHyperlink('https://help.syncfusion.com/document-processing/excel/spreadsheet/asp-net-mvc/overview', 'K3:K12', 'Open Guide');
spreadsheetObj.cellFormat({ fontWeight: 'bold', fontSize: '14pt', textAlign: 'center', verticalAlign: 'middle', backgroundColor: '#4472C4', color: '#FFFFFF' }, 'A1:K1');
spreadsheetObj.cellFormat({ fontWeight: 'bold', textAlign: 'center', backgroundColor: '#EAEAEA' }, 'A2:K2');
spreadsheetObj.numberFormat('$#,##0.00', 'F3:H13');
spreadsheetObj.addDataValidation({ type: 'WholeNumber', operator: 'Between', value1: '1', value2: '5', isHighlighted: true }, 'J3:J12');
spreadsheetObj.wrap('A3:A12', true);
spreadsheetObj.setBorder({ border: '1px solid #C8C8C8' }, 'A2:K13', 'Outer');
spreadsheetObj.setRowHeight(50, 0);
spreadsheetObj.setRowsHeight(30, ['1:13']);
spreadsheetObj.setColWidth(220, 0);
spreadsheetObj.setColumnsWidth(90, ['B:K']);
spreadsheetObj.resumeRefresh();
}
```

## API reference

### suspendRefresh()

Suspends visual updates in the Spreadsheet.

#### Behavior

- Prevents the UI from refreshing after each operation
- Allows multiple actions to be grouped together
- Keeps internal model updates running
- Must be paired with `resumeRefresh()`

### resumeRefresh()

Resumes visual updates and applies all pending changes.

#### Behavior

- Applies all operations performed after `suspendRefresh()`
- Refreshes the Spreadsheet UI once
- Improves rendering efficiency for bulk operations

## Code example

{% tabs %}
{% highlight razor tabtitle="CSHTML" %}
{% include code-snippet/spreadsheet/asp-net-mvc/batch-update-cs1/razor %}
{% endhighlight %}
{% highlight c# tabtitle="BatchUpdate.cs" %}
{% include code-snippet/spreadsheet/asp-net-mvc/batch-update-cs1/batchUpdate.cs %}
{% endhighlight %}
{% endtabs %}

## Common operations supported in batch update

The following types of operations can be performed between `suspendRefresh()` and `resumeRefresh()`:

- **Cell operations:** `updateCell`, `autoFill`, `clear`
- **Row and column operations:** `insertRow`, `insertColumn`, `hideRow`, `hideColumn`, `setRowsHeight`, `setRowHeight`, `setColWidth`, `setColumnsWidth`, `autoFit`
- **Formatting:** `cellFormat`, `numberFormat`, `wrap`, `setBorder`
- **Merge operations:** `merge`, `unMerge`
- **Hyperlinks:** `addHyperlink`, `removeHyperlink`
- **Data validation:** `addDataValidation`, `removeDataValidation`, `addInvalidHighlight`, `removeInvalidHighlight`
- **Conditional formatting:** `conditionalFormat`, `clearConditionalFormat`
- **Sheet operations:** `insertSheet`, `duplicateSheet`, `moveSheet`, `delete`
- **Protection:** `protectSheet`, `unProtectSheet`
- **Freeze panes:** `freezePanes`, `unfreezePanes`
- **Clipboard operations:** `cut`, `copy`, `paste`
- **Editing and navigation:** `find`, `replace`, `selectRange`, `goTo`
- **Charts:** `insertChart`, `deleteChart`
- **Images:** `insertImage`, `deleteImage`
- **Filtering:** `applyFilter`, `clearFilter`
- **Other actions:** `sort`, `calculateNow`, `addDefinedName`, `updateRange`

## Notes

- Use batch update only when multiple operations are executed together
- Avoid using it for few, simple actions
- It is most useful for initialization logic and programmatic bulk updates
- Data and model changes are processed during the suspended state; only visual refresh is delayed

## See Also

* [Data Binding](https://help.syncfusion.com/document-processing/excel/spreadsheet/asp-net-mvc/data-binding)
* [Worksheet](https://help.syncfusion.com/document-processing/excel/spreadsheet/asp-net-mvc/worksheet)
Loading