Interface ISheetWriter<TRow>
Writes one sheet's rows to the workbook. Obtained from AddSheet(string); a caller optionally sets column styles and widths, writes rows in order via StartRowAsync(CancellationToken), then ends the sheet. The sheet's leading structure is written when the first row starts, or at EndAsync(CancellationToken) for a sheet with no rows.
public interface ISheetWriter<TRow> : IDisposable, IAsyncDisposable
Type Parameters
TRowThe concrete IRowWriter this sheet produces.
- Inherited Members
Remarks
Only ExcelReader implements this interface, and a minor version can add members to it. See versioning and compatibility.
Methods
End()
Synchronous counterpart to EndAsync(CancellationToken): finalizes the sheet without the async/await machinery, for native/unmanaged callers whose ABI is synchronous.
[SuppressMessage("Naming", "CA1716:Identifiers should not match keywords", Justification = "'End' is not reserved in C#, this project's primary language; matches the sync/async naming pair (End/EndAsync) already used throughout this codebase (e.g. XlsSheetWriter.End).")]
void End()
EndAsync(CancellationToken)
Finalizes the sheet, writing any trailing structure so the sheet is complete within the workbook. The active row writer, if any, must already be disposed. No further rows may be started afterward.
ValueTask EndAsync(CancellationToken ct = default)
Parameters
ctCancellationTokenA token to cancel the operation.
Returns
SetColumnStyle(int, int)
Applies styleId to every cell of column columnIndex
that does not carry its own row style. Must be called before the first row is started.
void SetColumnStyle(int columnIndex, int styleId)
Parameters
columnIndexintThe 0-based column index.
styleIdintThe style to apply, from AddStyle(CellStyle).
Exceptions
- ArgumentOutOfRangeException
columnIndexis negative or beyond the format's last column, orstyleIdis negative or was never returned by AddStyle(CellStyle).- InvalidOperationException
The first row has already been started.
SetColumnWidth(int, double)
Sets the display width, in characters, of column columnIndex. Must be
called before the first row is started.
void SetColumnWidth(int columnIndex, double width)
Parameters
Exceptions
- ArgumentOutOfRangeException
columnIndexis negative or beyond the format's last column, orwidthis negative or greater than 255.- InvalidOperationException
The first row has already been started.
StartRow()
Synchronous counterpart to StartRowAsync(CancellationToken): begins the next row, without the async/await machinery, for native/unmanaged callers whose ABI is synchronous.
TRow StartRow()
Returns
- TRow
The writer for the new row.
StartRow(int)
Synchronous counterpart to StartRowAsync(int, CancellationToken): begins the
next row with styleId applied to its cells, without the async/await machinery.
TRow StartRow(int styleId)
Parameters
styleIdintThe style to apply to every cell of this row.
Returns
- TRow
The writer for the new row.
Exceptions
- ArgumentOutOfRangeException
styleIdis negative or was never returned by AddStyle(CellStyle).
StartRowAsync(int, CancellationToken)
Begins the next row, applying styleId (from AddStyle(CellStyle))
to its cells.
ValueTask<TRow> StartRowAsync(int styleId, CancellationToken ct = default)
Parameters
styleIdintThe style to apply to every cell of this row.
ctCancellationTokenA token to cancel the operation.
Returns
- ValueTask<TRow>
The writer for the new row.
Exceptions
- ArgumentOutOfRangeException
styleIdis negative or was never returned by AddStyle(CellStyle).
StartRowAsync(CancellationToken)
Begins the next row, in order starting from the first, and returns its writer. Only one row may be open (started and not yet disposed) at a time; the previous row's writer must be disposed before starting the next one.
ValueTask<TRow> StartRowAsync(CancellationToken ct = default)
Parameters
ctCancellationTokenA token to cancel the operation.
Returns
- ValueTask<TRow>
The writer for the new row.