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
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></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: 0 additions & 39 deletions Document-Processing/Excel/Spreadsheet/Blazor/cell-range.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,6 @@ documentation: ug
# Managing Cell Ranges in Blazor Spreadsheet component
A cell range is a set of selected cells in a Spreadsheet, typically specified using A1 notation (for example, `A1:B10`). A range may be a single cell or a contiguous block of cells that can be manipulated or processed collectively.

## 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.

## Autofill

Autofill is used to fill cells with data that follows a pattern or is based on data in other cells. It helps avoid entering repetitive data manually. The [AllowAutofill](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.SfSpreadsheet.html#Syncfusion_Blazor_Spreadsheet_SfSpreadsheet_AllowAutofill) property can be used to enable or disable this feature.
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 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 enable the execution of custom actions before and after a cell edit, allowing for validation, customization, and response handling.

### CellEditing

The `CellEditing` event is triggered before a cell enters edit mode, allowing for validation or cancellation of 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 | The zero-based row index of the cell being edited. |
| ColIndex | The zero-based column index of the cell being edited. |
| Address | The address of the cell being edited (e.g., "A1"). |
| Value | 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 raised after a cell's value has been successfully saved, providing details about the change and the action that triggered it.

**Purpose**

This event is useful for scenarios where post-editing actions are needed, such as logging the cell change, updating related data, or triggering additional UI updates.

**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 | The address of the cell whose value was saved (e.g., "A1"). |
| Value | The new value of the cell after saving. |
| OldValue | The original value of the cell before saving. |
| Action | 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
24 changes: 24 additions & 0 deletions Document-Processing/Excel/Spreadsheet/Blazor/events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
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. |
| [AutoFillActionEnd](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.AutofillActionEndEventArgs.html) | Triggers when an autofill operation completes. |
| [CellEditing](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.CellEditingEventArgs.html) | Triggers when a cell enters edit mode. |
| [CellSaved](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.CellSavedEventArgs.html) | Triggers when a cell's value is saved. |
| [CutCopyActionBegin](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.CutCopyActionBeginEventArgs.html) | Triggers when a cut or copy operation starts. |
| [HyperlinkClick](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.HyperlinkClickEventArgs.html) | Triggers when a hyperlink is clicked. |
| [HyperlinkCreated](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.HyperlinkCreatedEventArgs.html) | Triggers when a hyperlink is successfully added. |
| [HyperlinkCreating](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.HyperlinkCreatingEventArgs.html) | Triggers when a hyperlink is being created. |
| [Pasting](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.PastingEventArgs.html) | Triggers when a paste operation starts. |
Loading