Table of Contents

Class CsvSheetWriter

Namespace
ExcelReader.Core.Writer.Csv
Assembly
ExcelReader.Core.dll

The single sheet of a CSV "workbook". Adapts the flat ExcelReader.Core.Writer.Csv.CsvWriter to the ISheetWriter<TRow> contract that record writing drives.

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

Remarks

A CSV file is a single sheet, so the owning CsvWorkbookWriter exposes exactly one sheet and rejects a second AddSheet(string) call. The workbook owns the ExcelReader.Core.Writer.Csv.CsvWriter; this sheet only borrows it.

Methods

Dispose()

Synchronous counterpart to DisposeAsync(), for native/unmanaged callers whose ABI is synchronous. The workbook owns the ExcelReader.Core.Writer.Csv.CsvWriter's lifetime, so this only marks the sheet ended.

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

Exceptions

ObjectDisposedException

The sheet has already been ended.

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

Exceptions

ObjectDisposedException

The sheet has already been ended.

SetColumnStyle(int, int)

Validates its arguments are not negative, then no-ops: CSV has no column styles.

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

SetColumnWidth(int, double)

Validates its arguments, then no-ops: CSV has no column widths.

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.

StartRow()

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

public CsvRowWriter StartRow()

Returns

CsvRowWriter

Exceptions

ObjectDisposedException

The sheet has already been ended.

StartRow(int)

Validates styleId is not negative, then no-ops on it: CSV has no cell styles. Synchronous counterpart to StartRowAsync(int, CancellationToken), for native/unmanaged callers whose ABI is synchronous.

public CsvRowWriter StartRow(int styleId)

Parameters

styleId int

Returns

CsvRowWriter

Exceptions

ArgumentOutOfRangeException

styleId is negative.

StartRowAsync(int, CancellationToken)

Validates styleId is not negative, then no-ops: CSV has no cell styles.

public ValueTask<CsvRowWriter> 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<CsvRowWriter>

The writer for the new row.

Exceptions

ArgumentOutOfRangeException

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

ArgumentOutOfRangeException

styleId is negative.

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

Parameters

ct CancellationToken

A token to cancel the operation.

Returns

ValueTask<CsvRowWriter>

The writer for the new row.