API Reference
CsvRowWriter
Streams typed, projected, or data-reader rows to CSV without materializing a CsvDocument.
Inheritance
- Object
- CsvRowWriter
Constructors
public CsvRowWriter(TextWriter writer, CsvSaveOptions options = null, Boolean leaveOpen = false) #Initializes a streaming row writer.
Parameters
- writer System.IO.TextWriter
- Destination text writer.
- options OfficeIMO.CSV.CsvSaveOptions = null
- Optional CSV save options.
- leaveOpen System.Boolean = false
- Whether to leave the destination writer open when this writer is disposed.
Methods
public Void WriteDataReader(IDataReader reader) #VoidWrites all rows from an IDataReader using the reader field names as CSV columns.
Parameters
- reader System.Data.IDataReader
- Source data reader positioned before the first row.
public Void WriteDataReader(IDataReader reader, CancellationToken cancellationToken) #VoidWrites all rows from an IDataReader using the reader field names as CSV columns.
Parameters
- reader System.Data.IDataReader
- Source data reader positioned before the first row.
- cancellationToken System.Threading.CancellationToken
- Token observed while projecting and writing rows.
public Void WriteObject(Object item) #VoidWrites one object row, inferring columns from the first row.
Parameters
- item System.Object
- Object, dictionary, or flattened row to write.
public Void WriteRow(IReadOnlyList<String> columns, IReadOnlyList<Object> values) #VoidWrites one already-projected row using the provided column order.
Parameters
- columns System.Collections.Generic.IReadOnlyList{System.String}
- Column names for the first row and validation for later rows.
- values System.Collections.Generic.IReadOnlyList{System.Object}
- Values in the same order as columns.
public Void WriteRow(IReadOnlyList<String> columns, Object[] values) #VoidWrites one already-projected row using the provided column order.
Parameters
- columns System.Collections.Generic.IReadOnlyList{System.String}
- Column names for the first row and validation for later rows.
- values System.Object[]
- Values in the same order as columns.
public Void WriteRow(Object[] values) #VoidWrites one already-projected row using the column order that was established by a previous row.
Parameters
- values System.Object[]
- Values in the same order as the established CSV columns.
public Void WriteRows(IReadOnlyList<String> columns, IEnumerable<Object[]> rows) #VoidWrites already-projected rows using one shared column order.
Parameters
- columns System.Collections.Generic.IReadOnlyList{System.String}
- Column names shared by every row.
- rows System.Collections.Generic.IEnumerable{System.Object[]}
- Rows whose values use the same order as columns.
public Void WriteRow<TState>(Int32 valueCount, TState state, Func<TState, Int32, Object> valueAccessor) #VoidWrites one already-projected row using a caller-provided value accessor and the established column order.
Type Parameters
- TState
- State type used by the value accessor.
Parameters
- valueCount System.Int32
- Number of values exposed by valueAccessor.
- state ``0
- Caller state passed to valueAccessor for each column index.
- valueAccessor System.Func{``0,System.Int32,System.Object}
- Function that returns the value for a column index.
public Void WriteRow<TState>(IReadOnlyList<String> columns, Int32 valueCount, TState state, Func<TState, Int32, Object> valueAccessor) #VoidWrites one projected row using a caller-provided value accessor.
Type Parameters
- TState
- State type used by the value accessor.
Parameters
- columns System.Collections.Generic.IReadOnlyList{System.String}
- Column names for the first row and validation for later rows.
- valueCount System.Int32
- Number of values exposed by valueAccessor.
- state ``0
- Caller state passed to valueAccessor for each column index.
- valueAccessor System.Func{``0,System.Int32,System.Object}
- Function that returns the value for a column index.
public Void WriteTextRow(IReadOnlyList<String> columns, String[] values) #VoidWrites one already-formatted text row using the provided column order.
Parameters
- columns System.Collections.Generic.IReadOnlyList{System.String}
- Column names for the first row and validation for later rows.
- values System.String[]
- Text values in the same order as columns.
public Void WriteTextRow(String[] values) #VoidWrites one already-formatted text row using the column order that was established by a previous row.
Parameters
- values System.String[]
- Text values in the same order as the established CSV columns.
public Void WriteTextRows(IReadOnlyList<String> columns, IEnumerable<String[]> rows) #VoidWrites already-formatted text rows using one shared column order.
Parameters
- columns System.Collections.Generic.IReadOnlyList{System.String}
- Column names shared by every row.
- rows System.Collections.Generic.IEnumerable{System.String[]}
- Text rows whose values use the same order as columns.
public Void WriteTextRow<TState>(IReadOnlyList<String> columns, Int32 valueCount, TState state, Func<TState, Int32, String> valueAccessor) #VoidWrites one already-formatted text row using a caller-provided value accessor.
Type Parameters
- TState
- State type used by the value accessor.
Parameters
- columns System.Collections.Generic.IReadOnlyList{System.String}
- Column names for the first row and validation for later rows.
- valueCount System.Int32
- Number of values exposed by valueAccessor.
- state ``0
- Caller state passed to valueAccessor for each column index.
- valueAccessor System.Func{``0,System.Int32,System.String}
- Function that returns the already-formatted text for a column index.
public Void WriteTextRow<TState>(Int32 valueCount, TState state, Func<TState, Int32, String> valueAccessor) #VoidWrites one already-formatted text row using the column order that was established by a previous row.
Type Parameters
- TState
- State type used by the value accessor.
Parameters
- valueCount System.Int32
- Number of values exposed by valueAccessor.
- state ``0
- Caller state passed to valueAccessor for each column index.
- valueAccessor System.Func{``0,System.Int32,System.String}
- Function that returns the already-formatted text for a column index.
Inherited Methods
public override Boolean Equals(Object obj) #BooleanParameters
- obj Object
Properties
public Boolean HasRows { get; } #Gets whether at least one row was written.