Class SfSpreadsheet
Inherited Members
Namespace: Syncfusion.Blazor.Spreadsheet
Assembly: Syncfusion.Blazor.dll
Syntax
public class SfSpreadsheet : SfBaseComponent
Constructors
SfSpreadsheet()
Declaration
public SfSpreadsheet()
Properties
AllowHyperLink
Enables or disables the Hyperlink feature and its related functionalities in the spreadsheet.
Declaration
public bool AllowHyperLink { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | A boolean value that specifies whether the Hyperlink option is available.
The default value is |
Remarks
This property controls whether users can add Hyperlinks to cells in the spreadsheet using the context menu.
true
).
ContextMenuItems
Declaration
public object ContextMenuItems { get; set; }
Property Value
Type |
---|
System.Object |
DataSource
Declaration
public IEnumerable<object> DataSource { get; set; }
Property Value
Type |
---|
System.Collections.Generic.IEnumerable<System.Object> |
ID
Declaration
public string ID { get; set; }
Property Value
Type |
---|
System.String |
MaximumBlocks
Declaration
public int MaximumBlocks { get; set; }
Property Value
Type |
---|
System.Int32 |
SpreadsheetEvents
Gets or sets the spreadsheet events that are triggered on various actions in the spreadsheet.
Declaration
public SpreadsheetEvents SpreadsheetEvents { get; set; }
Property Value
Type |
---|
SpreadsheetEvents |
Remarks
The events can be used to customize the spreadsheet's behavior, perform custom actions on data, and handle user interactions with the spreadsheet.
Spreadsheets
Declaration
public List<Sheet> Spreadsheets { get; set; }
Property Value
Type |
---|
System.Collections.Generic.List<Sheet> |
Methods
AddHyperLinkAsync(String, String, String)
Adds a Hyperlink to the specified cell in the spreadsheet.
Declaration
public Task AddHyperLinkAsync(string hyperLink, string cellAddress, string displayText = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | hyperLink | The hyperlink URL or cell reference to be added. This can be a web URL or a reference to another cell, which can be within the same sheet or across different sheets. |
System.String | cellAddress | The address of the cell where the hyperlink will be inserted, specified using standard cell references (e.g., "A4", "B8"). |
System.String | displayText | The text to be displayed in the cell. This is an optional parameter. If not provided, the cell's existing value will be used as the display text. If the cell is empty, the hyperlink URL will be used as the display text by default. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the asynchronous operation of adding the hyperlink to the specified cell. |
Remarks
The method allows you to add a hyperlink to a specified cell in the spreadsheet.
- The first parameter
hyperLink
is used to define the hyperlink. It could be a URL or a reference to another cell, either in the same sheet or a different one. - The
cellAddress
parameter determines the location of the cell where the hyperlink will be added, using a standard cell notation (e.g., "A1"). - The optional
displayText
parameter allows you to specify custom display text. If omitted, the existing cell value will be used; if the cell is empty, the hyperlink itself will be displayed as the text.
Examples
// Example: Adding a hyperlink to a cell with a custom display text.
await spreadsheet.AddHyperLinkAsync("https://example.com", "A4", "Click here");
// Example: Adding a hyperlink to another sheet within the same spreadsheet.
await spreadsheet.AddHyperLinkAsync("#Sheet2!A1", "B2");
// Example: Adding a hyperlink without specifying display text (will use the cell value or hyperlink as the display text).
await spreadsheet.AddHyperLinkAsync("https://example.com", "A8");
BuildRenderTree(RenderTreeBuilder)
Declaration
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder | __builder |
CallStateHasChangedAsync()
Declaration
public Task CallStateHasChangedAsync()
Returns
Type |
---|
System.Threading.Tasks.Task |
CopyAsync(String)
Copies the specified cell or cells properties, such as value, format, style, etc., to the clipboard asynchronously.
Declaration
public Task CopyAsync(string cellAddress = "")
Parameters
Type | Name | Description |
---|---|---|
System.String | cellAddress | The address of the cell to be copied. If no address is provided, the default is an empty string, which may indicate copying the currently selected cell. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task that represents the asynchronous copy operation. |
CutAsync(String)
Cuts the specified cell or cells properties, such as value, format, style, etc., to the clipboard asynchronously.
Declaration
public Task CutAsync(string cellAddress = "")
Parameters
Type | Name | Description |
---|---|---|
System.String | cellAddress | The address of the cell to be cut. If no address is provided, the default is an empty string, which may indicate cutting the currently selected cell. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task that represents the asynchronous cut operation. |
OnAfterRenderAsync(Boolean)
Declaration
protected override Task OnAfterRenderAsync(bool firstRender)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | firstRender |
Returns
Type |
---|
System.Threading.Tasks.Task |
Overrides
OnInitializedAsync()
Declaration
protected override Task OnInitializedAsync()
Returns
Type |
---|
System.Threading.Tasks.Task |
Overrides
PasteAsync(String)
Pastes the copied clipboard content into the specified cell or cells asynchronously.
Declaration
public Task PasteAsync(string cellAddress = "")
Parameters
Type | Name | Description |
---|---|---|
System.String | cellAddress | The address of the cell where the content will be pasted. If no address is provided, the default is an empty string, which may indicate pasting from the currently selected cell. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task that represents the asynchronous paste operation. |
RemoveHyperLinkAsync(String)
Removes the hyperlink from the specified cell or range of cells in the spreadsheet.
Declaration
public Task RemoveHyperLinkAsync(string cellAddress)
Parameters
Type | Name | Description |
---|---|---|
System.String | cellAddress | The address of the cell or range of cells from which the hyperlink should be removed. This can be:
|
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the asynchronous operation of removing the hyperlink from the specified cell or range. |
Remarks
This method allows the removal of hyperlinks from either a single cell or a range of cells.
- If the
cellAddress
specifies only a cell reference (e.g., "A5"), the hyperlink from that specific cell is removed. - If a sheet name is included (e.g., "Sheet3!A10"), the method will remove the hyperlink from the specified cell or range on that sheet.
- Range-based removal is supported (e.g., "A1:A200" or "Sheet3!A10:A1000"), where all hyperlinks within the specified range will be removed.
Examples
// Example: Removing a hyperlink from a single cell in the active sheet.
await spreadsheet.RemoveHyperLinkAsync("A5");
// Example: Removing a hyperlink from a different sheet.
await spreadsheet.RemoveHyperLinkAsync("Sheet3!A10");
// Example: Removing hyperlinks from a range of cells.
await spreadsheet.RemoveHyperLinkAsync("A1:A200");
await spreadsheet.RemoveHyperLinkAsync("Sheet3!A10:A1000");