Table of Contents

Class XlsSheetWriter

Namespace
ExcelReader.Core.Writer.Xls
Assembly
ExcelReader.Core.dll

Writes a single sheet of a BIFF8 (.xls) workbook, buffering cell records in memory until the workbook is finalized. Rows beyond the BIFF8 65,536-row cap spill into an auto-generated continuation sheet.

public sealed class XlsSheetWriter : ISheetWriter<XlsRowWriter>, IDisposable, IAsyncDisposable
Inheritance
XlsSheetWriter
Implements
Inherited Members
Extension Methods

Methods

Dispose()

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

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()

Marks the sheet (and any continuation sheet it spilled into) as ended.

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

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 sheet 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 sheet has already been started.

StartRow()

Begins writing the next row, transparently spilling into a continuation sheet once the BIFF8 row cap is reached.

public XlsRowWriter StartRow()

Returns

XlsRowWriter

StartRow(int)

Begins writing the next row with styleId applied to its cells, transparently spilling into a continuation sheet once the BIFF8 row cap is reached.

public XlsRowWriter StartRow(int styleId)

Parameters

styleId int

Returns

XlsRowWriter

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<XlsRowWriter> 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<XlsRowWriter>

The writer for the new row.

Exceptions

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<XlsRowWriter> StartRowAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

A token to cancel the operation.

Returns

ValueTask<XlsRowWriter>

The writer for the new row.

Remarks

XLS buffers everything in memory, so this (and the other *Async members below) simply wraps the synchronous path in a completed ValueTask.