CsvWriterOptions Class
Options that control how CsvWriter and Utf8CsvWriter write CSV data.
public sealed class CsvWriterOptions : IEquatable<CsvWriterOptions>Remarks
The options are immutable. Use a with expression to create a copy with other values.
- Implements
Constructors
| Name | Description |
|---|---|
| CsvWriterOptions() |
CsvWriterOptions()
CsvWriterOptions.cspublic CsvWriterOptions()No documentation is available.
Properties
| Name | Description |
|---|---|
| BufferSize | Gets the size, in characters or in bytes, of the buffer of the writer. Default is 16384. |
| Default | Gets the default options: comma separator, double quote, \r\n line terminator, values quoted as needed. |
| EscapeFormulas | Gets a value indicating whether text values that a spreadsheet would run as a formula are escaped. Default is false. |
| FormatProvider | Gets the format provider used to format values. Default is null, which means CultureInfo.InvariantCulture. |
| NewLine | Gets the string written at the end of each row. Default is \r\n, as in RFC 4180. |
| Quote | Gets the character that quotes values. Default is ". When null, values are never quoted. |
| QuoteMode | Gets when values are quoted. Default is CsvQuoteMode.AsNeeded. |
| Separator | Gets the character that separates the values of a row. Default is ,. |
BufferSize
CsvWriterOptions.csDefault
CsvWriterOptions.csGets the default options: comma separator, double quote, \r\n line terminator, values quoted as needed.
public static CsvWriterOptions Default { get; }Property value
EscapeFormulas
CsvWriterOptions.csGets a value indicating whether text values that a spreadsheet would run as a formula are escaped. Default is false.
public bool EscapeFormulas { get; init; }Property value
Remarks
When true, a text value that starts with =, +, -, @, a tab or a carriage return is prefixed with a single quote, which prevents CSV injection when the file is opened in a spreadsheet. Values written from numbers and other formattable values are not escaped. When CsvWriterOptions.Quote is a single quote, an escaped value is always quoted and its prefix is doubled, so that it reads back with the prefix.
FormatProvider
CsvWriterOptions.csGets the format provider used to format values. Default is null, which means CultureInfo.InvariantCulture.
public IFormatProvider? FormatProvider { get; init; }Property value
NewLine
CsvWriterOptions.csQuote
CsvWriterOptions.csGets the character that quotes values. Default is ". When null, values are never quoted.
public char? Quote { get; init; }QuoteMode
CsvWriterOptions.csGets when values are quoted. Default is CsvQuoteMode.AsNeeded.
public CsvQuoteMode QuoteMode { get; init; }Property value
Separator
CsvWriterOptions.csGets the character that separates the values of a row. Default is ,.
public char Separator { get; init; }Methods
| Name | Description |
|---|---|
| Equals(CsvWriterOptions?) | |
| Equals(object?) | |
| GetHashCode() | |
| ToString() |
Equals overloads
Equals(CsvWriterOptions?)
public bool Equals(CsvWriterOptions? other)No documentation is available.
Equals(object?)
GetHashCode()
ToString()
Operators
| Name | Description |
|---|---|
| operator ==(CsvWriterOptions?, CsvWriterOptions?) | |
| operator !=(CsvWriterOptions?, CsvWriterOptions?) |
operator ==(CsvWriterOptions?, CsvWriterOptions?)
public static bool operator ==(CsvWriterOptions? left, CsvWriterOptions? right)No documentation is available.
operator !=(CsvWriterOptions?, CsvWriterOptions?)
public static bool operator !=(CsvWriterOptions? left, CsvWriterOptions? right)No documentation is available.