Skip to content
Merged
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
3 changes: 3 additions & 0 deletions Document-Processing-toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -5111,6 +5111,7 @@
<li><a href="/document-processing/excel/spreadsheet/blazor/cell-range">Cell Range</a></li>
<li><a href="/document-processing/excel/spreadsheet/blazor/editing">Editing</a></li>
<li><a href="/document-processing/excel/spreadsheet/blazor/formulas">Formulas</a></li>
<li><a href="/document-processing/excel/spreadsheet/blazor/formatting">Formatting</a></li>
<li><a href="/document-processing/excel/spreadsheet/blazor/contextmenu">Context Menu</a></li>
<li><a href="/document-processing/excel/spreadsheet/blazor/rows-and-columns">Rows and Columns</a></li>
<li><a href="/document-processing/excel/spreadsheet/blazor/filtering">Filtering</a></li>
Expand All @@ -5121,6 +5122,8 @@
<li><a href="/document-processing/excel/spreadsheet/blazor/protection">Protection</a></li>
<li><a href="/document-processing/excel/spreadsheet/blazor/undo-redo">Undo and Redo</a></li>
<li><a href="/document-processing/excel/spreadsheet/blazor/accessibility">Accessibility</a></li>
<li><a href="/document-processing/excel/spreadsheet/blazor/events">Events</a></li>
<li><a href="https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.SfSpreadsheet.html">API Reference</a></li>
</ul>
</li>
</ul>
Expand Down
39 changes: 2 additions & 37 deletions Document-Processing/Excel/Spreadsheet/Blazor/cell-range.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,7 @@ A cell range is a set of selected cells in a Spreadsheet, typically specified us

## Cell formatting

Cell formatting enhances the visual presentation of data by applying styles such as font changes, colors, borders, and alignment to individual cells or cell ranges. This helps organize content and emphasize important information for faster interpretation.

Cell formatting options include:

* **Bold** - Applies a heavier font weight to make the text stand out in the Spreadsheet.

* **Italic** - Slants the text to give it a distinct look, often used for emphasis or to highlight differences.

* **Underline** - Adds a line below the text, commonly used for emphasis or to indicate hyperlinks.

* **Strikethrough** - Draws a line through the text, often used to show completed tasks or outdated information.

* **Font Family** - Changes the typeface of the text (e.g., Arial, Calibri, Times New Roman, and more) to enhance readability or visual appeal.

* **Font Size** - Adjusts the size of the text to create visual hierarchy or improve readability in the Spreadsheet.

* **Font Color** - Changes the color of the text to improve visual hierarchy or to organize information using color codes.

* **Fill Color** - Adds color to the cell background to visually organize data or highlight important information.

* **Horizontal Alignment** - Controls the position of text from left to right within a cell. Options include:
* **Left** - Default for text
* **Center** - Useful for headings
* **Right** - Default for numbers

* **Vertical Alignment** - Controls the position of text from top to bottom within a cell. Options include:
* **Top** – Aligns content to the top of the cell
* **Middle** – Centers content vertically
* **Bottom** – Default alignment

* **Wrap Text** - Displays long content on multiple lines within a single cell, preventing it from overflowing into adjacent cells. To enable text wrapping:
1. Select the target cell or range (e.g., C5).
2. Go to the Home tab.
3. Click Wrap Text in the ribbon to toggle text wrapping for the selected cells.

Cell formatting can be applied or removed from a cell or range by using the options available in the component's built-in **Ribbon** under the **Home** tab.
To know more about cell formatting, refer [here](./formatting#text-and-cell-formatting).

## Autofill

Expand Down Expand Up @@ -164,7 +129,7 @@ The event uses the [AutofillActionBeginEventArgs](https://help.syncfusion.com/cr
{% endhighlight %}
{% endtabs %}

**AutofillActionEnd**
### AutofillActionEnd

The `AutofillActionEnd` event is triggered after an autofill operation has been successfully completed. This event provides detailed information about the completed autofill action, enabling further processing or logging if required.

Expand Down
99 changes: 99 additions & 0 deletions Document-Processing/Excel/Spreadsheet/Blazor/editing.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,105 @@ To exit edit mode without saving changes, press the **ESCAPE** key. This action

![Animation showing a user canceling a cell edit in the Blazor Spreadsheet component.](./images/cell-editing.gif)

## Events

The Blazor Spreadsheet component provides events that are triggered during editing operations, such as [CellEditing](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.CellEditingEventArgs.html) and [CellSaved](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.CellSavedEventArgs.html). These events allow you to perform custom actions before a cell enters edit mode and after its value has been successfully saved, enabling scenarios such as data validation or logging changes.

### CellEditing

The `CellEditing` event is triggered before a cell enters edit mode. It provides an opportunity to validate or cancel the edit operation.

**Purpose**

This event is useful for scenarios where cell editing needs to be controlled dynamically, such as restricting editing in specific ranges or preventing editing based on certain conditions.

**Event Arguments**

The event uses the [CellEditingEventArgs](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.CellEditingEventArgs.html) class, which includes the following properties:

| Event Arguments | Description |
|---|---|
| RowIndex (read-only)| The zero-based row index of the cell being edited. |
| ColIndex (read-only)| The zero-based column index of the cell being edited. |
| Address (read-only)| The address of the cell being edited (e.g., "Sheet1!A1"). |
| Value (read-only)| The current value of the cell before editing. |
| Cancel | Set to `true` to cancel the editing operation. |

{% tabs %}
{% highlight razor tabtitle="Index.razor" %}

@using Syncfusion.Blazor.Spreadsheet

<SfSpreadsheet DataSource="DataSourceBytes" CellEditing="OnCellEditing">
<SpreadsheetRibbon></SpreadsheetRibbon>
</SfSpreadsheet>

@code {
public byte[] DataSourceBytes { get; set; }

protected override void OnInitialized()
{
string filePath = "wwwroot/Sample.xlsx";
DataSourceBytes = File.ReadAllBytes(filePath);
}

private void OnCellEditing(CellEditingEventArgs args)
{
// Prevents editing in the first row.
if (args.RowIndex == 0)
{
args.Cancel = true;
}
}
}
{% endhighlight %}
{% endtabs %}

### CellSaved

The `CellSaved` event is triggered after a cell’s value has been successfully saved, providing details about the updated value and the action that caused the change (such as Edit, Cut, Paste, or Autofill).

**Purpose**

This event is useful for scenarios where post-editing actions are needed, such as logging the cell change or refreshing the UI.

**Event Arguments**

The event uses the [CellSavedEventArgs](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.CellSavedEventArgs.html) class, which includes the following properties:

| Event Arguments | Description |
|---|---|
| Address (read-only)| The address of the cell whose value was saved (e.g., "Sheet1!A1"). |
| Value (read-only)| The new value of the cell after saving. |
| OldValue (read-only)| The original value of the cell before saving. |
| Action (read-only)| The action that triggered the save (e.g., "Edit", "Cut", "Paste", "Autofill"). |

{% tabs %}
{% highlight razor tabtitle="Index.razor" %}

@using Syncfusion.Blazor.Spreadsheet

<SfSpreadsheet DataSource="DataSourceBytes" CellSaved="OnCellSaved">
<SpreadsheetRibbon></SpreadsheetRibbon>
</SfSpreadsheet>

@code {
public byte[] DataSourceBytes { get; set; }

protected override void OnInitialized()
{
string filePath = "wwwroot/Sample.xlsx";
DataSourceBytes = File.ReadAllBytes(filePath);
}
private void OnCellSaved(CellSavedEventArgs args)
{
// Log the cell change, including the action that triggered it.
Console.WriteLine($"Cell {args.Address} changed from '{args.OldValue}' to '{args.Value}' by {args.Action}.");
}
}
{% endhighlight %}
{% endtabs %}

## Cell editing in protected sheet

In a protected sheet, only unlocked ranges can be edited based on the sheet's protection settings. Attempting to modify a locked range triggers an error message, as shown below:
Expand Down
29 changes: 29 additions & 0 deletions Document-Processing/Excel/Spreadsheet/Blazor/events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
layout: post
title: Events in Blazor Spreadsheet Component | Syncfusion
description: Checkout and learn about the events in Syncfusion Blazor Spreadsheet component and more | Syncfusion.
platform: document-processing
control: Spreadsheet
documentation: ug
---

# Events in Blazor Spreadsheet Component

The Blazor Spreadsheet component provides various events that allow you to interact with the component and customize its behavior.

| Event Name | Description |
|---|---|
| [AutofillActionBegin](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.AutofillActionBeginEventArgs.html) | Triggers when an autofill operation starts. To know more about this event, refer [here](./cell-range#autofillactionbegin). |
| [AutofillActionEnd](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.AutofillActionEndEventArgs.html) | Triggers when an autofill operation completes. To know more about this event, refer [here](./cell-range#autofillactionend). |
| [BeforeSave](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.BeforeSaveEventArgs.html) | Triggers just before the workbook is saved. |
| [CellEditing](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.CellEditingEventArgs.html) | Triggers when a cell enters edit mode. To know more about this event, refer [here](./editing#cellediting). |
| [CellSaved](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.CellSavedEventArgs.html) | Triggers when a cell's value is saved. To know more about this event, refer [here](./editing#cellsaved). |
| [ColumnResizing](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.ColumnResizingEventArgs.html) | Triggers when a column is being resized. |
| [CutCopyActionBegin](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.CutCopyActionBeginEventArgs.html) | Triggers when a cut or copy operation starts. To know more about this event, refer [here](./clipboard#cutcopyactionbegin). |
| [HyperlinkClick](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.HyperlinkClickEventArgs.html) | Triggers when a hyperlink is clicked. To know more about this event, refer [here](./hyperlink#hyperlinkclick). |
| [HyperlinkCreated](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.HyperlinkCreatedEventArgs.html) | Triggers when a hyperlink is successfully added. To know more about this event, refer [here](./hyperlink#hyperlinkcreated). |
| [HyperlinkCreating](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.HyperlinkCreatingEventArgs.html) | Triggers when a hyperlink is being created. To know more about this event, refer [here](./hyperlink#hyperlinkcreating). |
| [Pasting](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.PastingEventArgs.html) | Triggers when a paste operation starts. To know more about this event, refer [here](./clipboard#pasting). |
| [RowResizing](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.RowResizingEventArgs.html) | Triggers when a row is being resized. |
| [Selected](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.SelectedEventArgs.html) | Triggers when a cell or range of cells is selected. |
| [WorksheetAdding](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.WorksheetAddingEventArgs.html) | Triggers before a new worksheet is added. |
Loading