Class CsvRowWriter
Writes the fields of a single CSV row, quoting a field only when it contains the delimiter, quote character, carriage return, or line feed.
public sealed class CsvRowWriter : IRowWriter, IDisposable, IAsyncDisposable
- Inheritance
-
CsvRowWriter
- Implements
- Inherited Members
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.
Skip(int)
Advances past count columns without writing any cell for them, leaving
them blank when the row is read back.
public void Skip(int count = 1)
Parameters
countintThe number of columns to skip; must not be negative.
Write(bool)
Writes a boolean cell.
public void Write(bool value)
Parameters
valueboolThe value to write.
Remarks
Writes lowercase "true"/"false" — the only spellings ColumnParserFactory's IsTruthy recognizes besides "1", so a written bool round-trips through ExcelParser<T> unchanged.
Write(DateOnly)
Writes a date-only cell (no time component).
public void Write(DateOnly value)
Parameters
valueDateOnlyThe value to write.
Remarks
Writes the value as ISO "yyyy-MM-dd" (the "O" round-trip form), which the CSV text-date parser reads back.
Write(DateTime)
Writes a date/time cell.
public void Write(DateTime value)
Parameters
valueDateTimeThe value to write.
Remarks
Writes the round-trip ISO 8601 ("O") format: unambiguous, culture-independent, and — for the common no-offset shape — exactly what ColumnParserFactory's CSV date fast path recognizes.
Write(bool?)
Writes a boolean cell, or a blank/empty cell if value is null.
public void Write(bool? value)
Parameters
valuebool?The value to write.
Write(DateOnly?)
Writes a date-only cell, or a blank/empty cell if value is null.
public void Write(DateOnly? value)
Parameters
valueDateOnly?The value to write.
Write(DateTime?)
Writes a date/time cell, or a blank/empty cell if value is null.
public void Write(DateTime? value)
Parameters
valueDateTime?The value to write.
Write(TimeOnly?)
Writes a time-of-day cell, or a blank/empty cell if value is null.
public void Write(TimeOnly? value)
Parameters
valueTimeOnly?The value to write.
Write(string?)
Writes a text cell, or a blank/empty cell if value is null.
public void Write(string? value)
Parameters
valuestringThe text to write.
Exceptions
- ArgumentException
valueexceeds Excel's per-cell text limit (32,767 characters).
Write(TimeOnly)
Writes a time-of-day cell (no date component).
public void Write(TimeOnly value)
Parameters
valueTimeOnlyThe value to write.
Remarks
Writes the value as an Excel-style time serial (fraction of a 24h day): a plain number the parser reconstructs via TryGetDouble, matching how the XLSX/XLSB row writers store it.
WriteUtf8(ReadOnlySpan<byte>)
Writes a text cell from UTF-8 bytes, producing exactly the cell Write(string?) would for the decoded text. Writers whose output is UTF-8 copy plain text through without materializing a string; the default implementation decodes and delegates.
public void WriteUtf8(ReadOnlySpan<byte> utf8)
Parameters
utf8ReadOnlySpan<byte>The UTF-8 encoded text to write. Invalid sequences are replaced as UTF8 decoding would.
Exceptions
- ArgumentException
The decoded text exceeds Excel's per-cell text limit (32,767 characters).
Write<T>(T?)
Writes a numeric cell, or a blank/empty cell if value is null.
public void Write<T>(T? value) where T : struct, IUtf8SpanFormattable
Parameters
valueT?The value to write.
Type Parameters
TThe underlying numeric value type to write.
Write<T>(T)
public void Write<T>(T value) where T : IUtf8SpanFormattable
Parameters
valueTThe value to write.
Type Parameters
TThe numeric value type to write.
Remarks
Constrained to IUtf8SpanFormattable (not ISpanFormattable): CSV output is UTF-8, so numbers format straight to bytes with no char buffer or transcode. Every BCL numeric type implements it.