Class CsvSheetWriter
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
ctCancellationTokenA token to cancel the operation.
Returns
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
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.
- ArgumentOutOfRangeException
columnIndexorstyleIdis negative.
SetColumnWidth(int, double)
Validates its arguments, then no-ops: CSV has no column widths.
public 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.
- ArgumentOutOfRangeException
columnIndexorwidthis negative.
StartRow()
Synchronous counterpart to StartRowAsync(CancellationToken), for native/unmanaged callers whose ABI is synchronous.
public CsvRowWriter StartRow()
Returns
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
styleIdint
Returns
Exceptions
- ArgumentOutOfRangeException
styleIdis 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
styleIdintThe style to apply to every cell of this row.
ctCancellationTokenA token to cancel the operation.
Returns
- ValueTask<CsvRowWriter>
The writer for the new row.
Exceptions
- ArgumentOutOfRangeException
styleIdis negative or was never returned by AddStyle(CellStyle).- ArgumentOutOfRangeException
styleIdis 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
ctCancellationTokenA token to cancel the operation.
Returns
- ValueTask<CsvRowWriter>
The writer for the new row.