Skip to content

Commit 63aa3e5

Browse files
Merge pull request #1978 from syncfusion-content/959853-SpreadsheetDoc
959853: Create User Guide Documentation for AutoFill Series, GetData and GetActiveWorksheet in Blazor Spreadsheet
2 parents bfda323 + 96c39d8 commit 63aa3e5

File tree

5 files changed

+112
-10
lines changed

5 files changed

+112
-10
lines changed

Document-Processing/Excel/Spreadsheet/Blazor/cell-range.md

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,35 @@ Autofill can be performed in one of the following ways:
2525
* Drag and drop the cell using the fill handle element.
2626
* Use the [AutofillAsync()](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.SfSpreadsheet.html#Syncfusion_Blazor_Spreadsheet_SfSpreadsheet_AutofillAsync_System_String_System_String_) method programmatically.
2727

28+
### Autofill options
29+
30+
Autofill supports multiple behaviors that control how adjacent cells are populated when using the fill handle. The available options are:
31+
32+
- Copy Cells
33+
- Fill Series
34+
- Fill Formatting Only
35+
- Fill Without Formatting
36+
37+
#### Copy Cells
38+
39+
Copies the source cell content and formatting to the selected destination range. After dragging the fill handle from the selection to the target area, choose **Copy Cells** from the **AutoFillOption** menu to replicate both values and presentation. When the source contains formulas, relative references are adjusted to match the destination.
40+
41+
#### Fill Series
42+
43+
Extends a recognizable pattern—such as numbers (1, 2, 3), days or months (Mon, Tue; Jan, Feb), or dates—into the destination range while preserving the source formatting. Drag the fill handle to the target cells and choose **Fill Series** in the **AutoFillOptions** menu to continue the detected sequence.
44+
45+
#### Fill Formatting Only
46+
47+
Applies only the source styling—number format, font, fill color, borders, and alignment—to the destination range, leaving existing values unchanged. Drag the fill handle over the target cells and select **Fill Formatting Only** from the **AutoFillOptions** menu to unify appearance without altering data.
48+
49+
#### Fill Without Formatting
50+
51+
Continues the detected series into the destination range but retains the destination’s existing formatting. After dragging the fill handle, choose **Fill Without Formatting** from the **AutoFillOptions** menu to apply only the new values while keeping the target style intact.
52+
53+
The following illustration demonstrates the use of autofill in the Spreadsheet component.
54+
55+
![Autofill Illustration](images/autofill.gif)
56+
2857
The `AutofillAsync()` method accepts string parameters in A1 notation for `fillRange` and `dataRange`. The available parameters are:
2958

3059
| Parameter | Type | Description |
@@ -65,10 +94,6 @@ The `AutofillAsync()` method accepts string parameters in A1 notation for `fillR
6594
{% endhighlight %}
6695
{% endtabs %}
6796

68-
The following illustration demonstrates the use of autofill in the Spreadsheet component.
69-
70-
![Autofill Illustration](images/autofill.gif)
71-
7297
## Events
7398

7499
The Blazor Spreadsheet provides events that are triggered during autofill operations, such as [AutofillActionBegin](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.AutofillActionBeginEventArgs.html) and [AutofillActionEnd](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.AutofillActionEndEventArgs.html). These events enable the execution of custom actions before and after an autofill operation, allowing for validation, customization, and response handling.

Document-Processing/Excel/Spreadsheet/Blazor/formatting.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Number formats can be applied programmatically to the current selection or a spe
9090
{% endhighlight %}
9191
{% endtabs %}
9292

93-
> If the built-in formats do not meet specific requirements, custom patterns can be applied programmatically using the `NumberFormatAsync` method. Patterns must be compatible with Excel-style format strings.
93+
N> If the built-in formats do not meet specific requirements, custom patterns can be applied programmatically using the `NumberFormatAsync` method. Patterns must be compatible with Excel-style format strings.
9494

9595
## Text and Cell Formatting
9696

@@ -178,7 +178,7 @@ Borders can be applied through the UI using the following method:
178178

179179
### Applying Borders Programmatically
180180

181-
Borders can be applied programmatically to a specific cell or range of cells using the [SetBordersAsync](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.SfSpreadsheet.html#Syncfusion_Blazor_Spreadsheet_SfSpreadsheet_SetBordersAsync_Syncfusion_Blazor_Spreadsheet_BorderType_Syncfusion_XlsIO_ExcelLineStyle_System_String_System_String) method. The available parameters in the `SetBordersAsync` method are:
181+
Borders can be applied programmatically to a specific cell or range of cells using the [SetBordersAsync](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.SfSpreadsheet.html#Syncfusion_Blazor_Spreadsheet_SfSpreadsheet_SetBordersAsync_Syncfusion_Blazor_Spreadsheet_BorderType_Syncfusion_XlsIO_ExcelLineStyle_System_String_System_String_) method. The available parameters in the `SetBordersAsync` method are:
182182

183183
| Parameter | Type | Description |
184184
| -- | -- | -- |
11.9 KB
Loading

Document-Processing/Excel/Spreadsheet/Blazor/merge-cell.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ N> Clicking the **Merge Cells** button (not the drop-down) applies the default a
4747

4848
### Merge cells programmatically
4949

50-
The [MergeAsync](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.SfSpreadsheet.html#Syncfusion_Blazor_Spreadsheet_SfSpreadsheet_MergeAsync_System_String_System_String_) method merges cells based on the specified merge type. If the **cellRange** parameter is not provided, the current selection is used. This method provides a programmatic way to merge cells without using the UI. The available parameters in the `MergeAsync` method are:
50+
The [MergeAsync](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.SfSpreadsheet.html#Syncfusion_Blazor_Spreadsheet_SfSpreadsheet_MergeAsync_Syncfusion_Blazor_Spreadsheet_MergeType_System_String_) method merges cells based on the specified merge type. If the **cellRange** parameter is not provided, the current selection is used. This method provides a programmatic way to merge cells without using the UI. The available parameters in the `MergeAsync` method are:
5151

5252
| Parameter | Type | Description |
5353
| -- | -- | -- |
54-
| mergeType | **MergeType** | Specifies the merge behavior.<br><br> the Default MergeType is `MergeType.Cells`. Supported values:<br> - `Cells` - Merge the entire selection into one cell and preserve the top-left value;<br> - `Center` - Merge the entire selection and horizontally center the resulting cell’s content;<br> - `Across` - For each row in the selection, merge the cells across columns and preserve each row’s first cell value. |
54+
| mergeType | **MergeType** | Specifies the merge behavior.<br><br> The default **MergeType** is `MergeType.Cells`. Supported values:<br> `Cells` - Merge the entire selection into one cell and preserve the top-left value;<br> `Center`- Merge the entire selection and horizontally center the resulting cell’s content;<br> `Across` - For each row in the selection, merge the cells across columns and preserve each row’s first cell value. |
5555
| cellRange | string (optional) | Specifies the A1-style address of the range to unmerge (e.g., `"A1:D1"`). If not provided, the currently selected range will be unmerged. |
5656

5757
{% tabs %}
@@ -112,7 +112,7 @@ The [MergeAsync](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreads
112112

113113
### Unmerge cells programmatically.
114114

115-
The [UnmergeAsync](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.SfSpreadsheet.html#Syncfusion_Blazor_Spreadsheet_SfSpreadsheet_UnmergeAsync_System_String_System_String_) method reverses a merge and restores individual cells. If the **cellRange** parameter is not provided, the current selection cell is unmerged. This method provides a programmatic way to unmerge cells without using the UI. The available parameters in the `UnmergeAsync` method are:
115+
The [UnmergeAsync](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.SfSpreadsheet.html#Syncfusion_Blazor_Spreadsheet_SfSpreadsheet_UnmergeAsync_System_String_) method reverses a merge and restores individual cells. If the **cellRange** parameter is not provided, the current selection cell is unmerged. This method provides a programmatic way to unmerge cells without using the UI. The available parameters in the `UnmergeAsync` method are:
116116

117117
| Parameter | Type | Description |
118118
| -- | -- | -- |
@@ -149,7 +149,7 @@ The [UnmergeAsync](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Sprea
149149
{% endhighlight %}
150150
{% endtabs %}
151151

152-
### Limitations of Merge
152+
## Limitations of Merge
153153

154154
When merging cells in the Blazor Spreadsheet, certain constraints apply to ensure data integrity. In these cases, validation messages are displayed:
155155

Document-Processing/Excel/Spreadsheet/Blazor/worksheet.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,83 @@ This method inserts one or more sheets at a specified position in the workbook w
7171
{% endhighlight %}
7272
{% endtabs %}
7373

74+
75+
### Get Active Worksheet Programmatically
76+
77+
The [GetActiveWorksheet](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.SfSpreadsheet.html#Syncfusion_Blazor_Spreadsheet_SfSpreadsheet_GetActiveWorksheet) method retrieves properties of the active worksheet. This method is useful when it is necessary to obtain details about the currently active sheet. If no worksheet is active, this method returns null.
78+
79+
**Retrieve the active worksheet**
80+
81+
This method retrieves details of the currently active worksheet. Properties of the active worksheet, such as sheet name, index, or selected range, can be accessed for diagnostics, automation, or integration with other logic.
82+
83+
{% tabs %}
84+
{% highlight razor %}
85+
@using Syncfusion.Blazor.Spreadsheet
86+
87+
<button @onclick="GetActiveWorksheet">Get Active Worksheet</button>
88+
<SfSpreadsheet @ref=SpreadsheetInstance DataSource="DataSourceBytes">
89+
<SpreadsheetRibbon></SpreadsheetRibbon>
90+
</SfSpreadsheet>
91+
92+
@code {
93+
public byte[] DataSourceBytes { get; set; }
94+
public SfSpreadsheet SpreadsheetInstance;
95+
96+
protected override void OnInitialized()
97+
{
98+
string filePath = "wwwroot/Sample.xlsx";
99+
DataSourceBytes = File.ReadAllBytes(filePath);
100+
}
101+
102+
public async Task GetActiveWorksheet()
103+
{
104+
// Get the active sheet snapshot
105+
var active = SpreadsheetInstance.GetActiveWorksheet();
106+
}
107+
}
108+
{% endhighlight %}
109+
{% endtabs %}
110+
111+
### Get Worksheet Data Programmatically
112+
113+
The [GetData](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Spreadsheet.SfSpreadsheet.html#Syncfusion_Blazor_Spreadsheet_SfSpreadsheet_GetData_System_String_) method retrieves content from the worksheet. This method provides data as a dictionary, where each entry consists of a cell address and its associated `CellData` object. The returned data includes the actual value, number format, display text, wrap and lock status, hyperlinks, and calculated style of each cell in the target area. If the specified cell address is invalid or not set, the method returns null.
114+
115+
**Retrieve cell or range data from an active worksheet**
116+
117+
Call this method by passing the desired cell or range as the address. For example, provide a reference such as "A1" for a single cell, "A2:B5" for a range, or "Sheet1!A2:B5" to target a range on a specific sheet. The result can be iterated to read individual cell data for further processing, logging, or custom display.
118+
119+
| Parameter | Type | Description |
120+
| :-- | :-- | :-- |
121+
| cellAddress | string | Specifies the cell or range to read. Supports addresses such as "A1", "A2:B5", or "Sheet1!A2:B5". If omitted or invalid, the return value is null. |
122+
123+
{% tabs %}
124+
{% highlight razor %}
125+
@using Syncfusion.Blazor.Spreadsheet
126+
127+
<button @onclick="GetData">Get Data</button>
128+
<SfSpreadsheet @ref=SpreadsheetInstance DataSource="DataSourceBytes">
129+
<SpreadsheetRibbon></SpreadsheetRibbon>
130+
</SfSpreadsheet>
131+
132+
@code {
133+
public byte[] DataSourceBytes { get; set; }
134+
public SfSpreadsheet SpreadsheetInstance;
135+
136+
protected override void OnInitialized()
137+
{
138+
string filePath = "wwwroot/Sample.xlsx";
139+
DataSourceBytes = File.ReadAllBytes(filePath);
140+
}
141+
142+
public async Task GetData()
143+
{
144+
// Get the cellData snapshot
145+
var data = SpreadsheetInstance.GetData("Sheet2!D5:E6");
146+
}
147+
}
148+
{% endhighlight %}
149+
{% endtabs %}
150+
74151
**Insert a single sheet with a user-defined name**
75152

76153
This method adds one sheet at a specific position with a user-defined name. Each call to this method adds only one sheet. Using meaningful names like "Budget" or "Inventory" makes the workbook easier to understand. If a negative index value is provided, the method will exit without adding any sheet.

0 commit comments

Comments
 (0)