Table of Contents

Class XlsbSheetWriter

Namespace
ExcelReader.Core.Writer.Xlsb
Assembly
ExcelReader.Core.dll

Writes a single worksheet's rows into an .xlsb workbook produced by XlsbWorkbookWriter.

public sealed class XlsbSheetWriter : ITableSheetWriter<XlsbRowWriter>, ISheetWriter<XlsbRowWriter>, IDisposable, IAsyncDisposable
Inheritance
XlsbSheetWriter
Implements
Inherited Members
Extension Methods

Methods

BeginTable(string, IReadOnlyList<string>, ExcelTableOptions?)

Writes a header row with columns at the sheet's next row and opens a table there. The table covers every row written until EndTable() or the end of the sheet.

public void BeginTable(string name, IReadOnlyList<string> columns, ExcelTableOptions? options = null)

Parameters

name string

The table name: unique in the workbook, ignoring case, and valid as an Excel name.

columns IReadOnlyList<string>

The column names, written as the header row.

options ExcelTableOptions

Position and style. Defaults to Default.

Exceptions

ArgumentNullException

name or columns is null.

ArgumentException

The name, a column name or the style is not valid, or the name is already used in this workbook.

ArgumentOutOfRangeException

FirstColumn is negative.

InvalidOperationException

A table is already open on this sheet, or a row is still active.

ObjectDisposedException

The sheet has already been ended.

ExcelLimitExceededException

The sheet has no room left for a header row and a data row.

BeginTableAsync(string, IReadOnlyList<string>, ExcelTableOptions?, CancellationToken)

Writes a header row with columns at the sheet's next row and opens a table there. The table covers every row written until EndTable() or the end of the sheet.

public ValueTask BeginTableAsync(string name, IReadOnlyList<string> columns, ExcelTableOptions? options = null, CancellationToken ct = default)

Parameters

name string

The table name: unique in the workbook, ignoring case, and valid as an Excel name.

columns IReadOnlyList<string>

The column names, written as the header row.

options ExcelTableOptions

Position and style. Defaults to Default.

ct CancellationToken

A token to cancel the header write.

Returns

ValueTask

Exceptions

ArgumentNullException

name or columns is null.

ArgumentException

The name, a column name or the style is not valid, or the name is already used in this workbook.

ArgumentOutOfRangeException

FirstColumn is negative.

InvalidOperationException

A table is already open on this sheet, or a row is still active.

ObjectDisposedException

The sheet has already been ended.

ExcelLimitExceededException

The sheet has no room left for a header row and a data row.

Dispose()

Synchronous counterpart to DisposeAsync(), for native/unmanaged callers whose ABI is synchronous.

public void Dispose()

DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

public ValueTask DisposeAsync()

Returns

ValueTask

A task that represents the asynchronous dispose operation.

End()

Synchronous counterpart to EndAsync(CancellationToken), for native/unmanaged callers whose ABI is synchronous.

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

public ValueTask EndAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

A token to cancel the operation.

Returns

ValueTask

EndTable()

Closes the open table at the last row written. Writes nothing; the table is stored when the sheet ends.

public void EndTable()

Exceptions

InvalidOperationException

No table is open on this sheet.

ObjectDisposedException

The sheet has already been ended.

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.

public void SetColumnStyle(int columnIndex, int styleId)

Parameters

columnIndex int

The 0-based column index.

styleId int

The style to apply, from AddStyle(CellStyle).

Exceptions

ArgumentOutOfRangeException

columnIndex is negative or beyond the format's last column, or styleId is negative or was never returned by AddStyle(CellStyle).

InvalidOperationException

The first row has already been started.

ArgumentOutOfRangeException

columnIndex is negative, or styleId is 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.

public void SetColumnWidth(int columnIndex, double width)

Parameters

columnIndex int

The 0-based column index.

width double

The column width, in characters.

Exceptions

ArgumentOutOfRangeException

columnIndex is negative or beyond the format's last column, or width is negative or greater than 255.

InvalidOperationException

The first row has already been started.

ArgumentOutOfRangeException

columnIndex or width is negative.

InvalidOperationException

The first row has already been started.

StartRow()

Synchronous counterpart to StartRow(), for native/unmanaged callers whose ABI is synchronous.

public XlsbRowWriter StartRow()

Returns

XlsbRowWriter

StartRow(int)

Synchronous counterpart to StartRow(int), for native/unmanaged callers whose ABI is synchronous.

public XlsbRowWriter StartRow(int styleId)

Parameters

styleId int

Returns

XlsbRowWriter

Exceptions

ArgumentOutOfRangeException

styleId is negative or was never returned by AddStyle(CellStyle).

StartRowAsync(int, CancellationToken)

Begins the next row, applying styleId (from AddStyle(CellStyle)) to its cells.

public ValueTask<XlsbRowWriter> StartRowAsync(int styleId, CancellationToken ct = default)

Parameters

styleId int

The style to apply to every cell of this row.

ct CancellationToken

A token to cancel the operation.

Returns

ValueTask<XlsbRowWriter>

The writer for the new row.

Exceptions

ArgumentOutOfRangeException

styleId is negative or was never returned by AddStyle(CellStyle).

ArgumentOutOfRangeException

styleId is 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.

public ValueTask<XlsbRowWriter> StartRowAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

A token to cancel the operation.

Returns

ValueTask<XlsbRowWriter>

The writer for the new row.

WriteRow(ReadOnlySpan<XlsbCell>)

Writes an entire row in one call, mapping each element of values to a column starting at 0.

public void WriteRow(ReadOnlySpan<XlsbCell> values)

Parameters

values ReadOnlySpan<XlsbCell>