Table of Contents

Class CsvWriterOptions

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

Configures the dialect, encoding, and record terminator used when writing a CSV file.

public sealed record CsvWriterOptions : IEquatable<CsvWriterOptions>
Inheritance
CsvWriterOptions
Implements
Inherited Members

Remarks

Mirrors CsvReaderOptions property for property, so a file written with one set of settings reads back with the matching set.

Properties

Default

The default options: comma-delimited, double-quote-quoted, UTF-8 with no byte-order mark, CRLF-terminated.

public static CsvWriterOptions Default { get; }

Property Value

CsvWriterOptions

Delimiter

The byte written between fields. Defaults to ,.

public byte Delimiter { get; init; }

Property Value

byte

Encoding

The text encoding to write. When not null, output is transcoded from UTF-8 as it is written. Defaults to null, meaning UTF-8 is written directly.

public Encoding? Encoding { get; init; }

Property Value

Encoding

Remarks

Counterpart to Encoding: fields are always formatted as UTF-8 internally, so a non-UTF-8 target is transcoded on the way out.

NewLine

The byte sequence written after each record. Defaults to CarriageReturnLineFeed, which is what RFC 4180 specifies.

public CsvNewLine NewLine { get; init; }

Property Value

CsvNewLine

Remarks

Fields containing \r or \n are quoted either way, so the choice does not change how the file reads back.

Quote

The byte used to quote a field that contains the delimiter, itself, or a line break. Defaults to ".

public byte Quote { get; init; }

Property Value

byte

WriteByteOrderMark

Whether the encoding's byte-order mark is written before the first record. Defaults to false.

public bool WriteByteOrderMark { get; init; }

Property Value

bool

Remarks

Counterpart to DetectEncodingFromByteOrderMark. Writing one is what lets Excel open a UTF-8 file as UTF-8 rather than as the system code page.