Represents a workbook in a spreadsheet.
Object
Namespace: Radzen.Documents.Spreadsheet
Assembly: Radzen.Blazor.dll
public class WorkbookInitializes a new instance of the Workbook class.
public Workbook()Gets or sets the culture used to parse typed cell input and to render values and number formats. If not set, falls back to CurrentCulture. File storage (XLSX, CSV) and formula storage always use the invariant culture regardless of this setting.
public Globalization.CultureInfo Culture { get; set; }
| Type | Description |
|---|---|
| Globalization.CultureInfo | Gets or sets the culture used to parse typed cell input and to render values and number formats. If not set, falls back to CurrentCulture. File storage (XLSX, CSV) and formula storage always use the invariant culture regardless of this setting. |
Gets or sets the workbook protection settings.
public Documents.Spreadsheet.WorkbookProtection Protection { get; set; }
| Type | Description |
|---|---|
| Documents.Spreadsheet.WorkbookProtection | Gets or sets the workbook protection settings. |
Gets the collection of sheets in the workbook.
public IReadOnlyList<Documents.Spreadsheet.Worksheet> Sheets { get; }
| Type | Description |
|---|---|
| IReadOnlyList<Documents.Spreadsheet.Worksheet> | Gets the collection of sheets in the workbook. |
Adds a new sheet to the workbook with the specified name, rows, and columns.
public Documents.Spreadsheet.Worksheet AddSheet(string name, int rows, int columns)
| Type | Name | Description |
|---|---|---|
| string | name | |
| int | rows | |
| int | columns |
| Type | Description |
|---|---|
| Documents.Spreadsheet.Worksheet |
Adds a new sheet to the workbook with the specified name, rows, and columns.
public void AddSheet(Documents.Spreadsheet.Worksheet sheet)
| Type | Name | Description |
|---|---|---|
| Documents.Spreadsheet.Worksheet | sheet |
Gets the sheet with the specified name or null if not found.
public Documents.Spreadsheet.Worksheet GetSheet(string name)
| Type | Name | Description |
|---|---|---|
| string | name |
| Type | Description |
|---|---|
| Documents.Spreadsheet.Worksheet |
Gets the index of the specified sheet in the workbook.
public int IndexOf(Documents.Spreadsheet.Worksheet sheet)
| Type | Name | Description |
|---|---|---|
| Documents.Spreadsheet.Worksheet | sheet | The sheet to find. |
| Type | Description |
|---|---|
| int | The zero-based index of the sheet, or -1 if not found. |
Loads a CSV stream into a new Workbook with a single sheet.
public static Documents.Spreadsheet.Workbook LoadFromCsv(IO.Stream stream, Documents.Spreadsheet.CsvImportOptions options)
| Type | Name | Description |
|---|---|---|
| IO.Stream | stream | Source stream. |
| Documents.Spreadsheet.CsvImportOptions | options | CSV options. When null, defaults are used. |
| Type | Description |
|---|---|
| Documents.Spreadsheet.Workbook |
Loads a workbook from the specified stream in the Open XML Spreadsheet format (XLSX).
public static Documents.Spreadsheet.Workbook LoadFromStream(IO.Stream stream)
| Type | Name | Description |
|---|---|---|
| IO.Stream | stream |
| Type | Description |
|---|---|
| Documents.Spreadsheet.Workbook |
Moves a sheet from one position to another.
public void MoveSheet(int fromIndex, int toIndex)
| Type | Name | Description |
|---|---|---|
| int | fromIndex | The current index of the sheet. |
| int | toIndex | The target index for the sheet. |
Removes a sheet from the workbook.
public bool RemoveSheet(Documents.Spreadsheet.Worksheet sheet)
| Type | Name | Description |
|---|---|---|
| Documents.Spreadsheet.Worksheet | sheet | The sheet to remove. |
| Type | Description |
|---|---|
| bool | true if the sheet was removed; otherwise false. |
Saves a single sheet of the workbook to the specified stream in CSV format. By default the first sheet is exported; pass Sheet to choose a different one. CSV is single-sheet by design, matching Excel's "Save As CSV" behavior.
public void SaveAsCsv(IO.Stream stream, Documents.Spreadsheet.CsvExportOptions options)
| Type | Name | Description |
|---|---|---|
| IO.Stream | stream | Destination stream. |
| Documents.Spreadsheet.CsvExportOptions | options | CSV options. When null, defaults are used (comma separator, UTF-8 with BOM, CRLF line endings, RFC 4180 minimal quoting). |
Saves the workbook to the specified stream in the Open XML Spreadsheet format (XLSX).
public void SaveToStream(IO.Stream stream)
| Type | Name | Description |
|---|---|---|
| IO.Stream | stream |