API Reference

Class

CsvRowWriter

Namespace OfficeIMO.CSV
Assembly OfficeIMO.CSV
Implements
IDisposable
Modifiers sealed

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 requiredposition: 0
Destination text writer.
options OfficeIMO.CSV.CsvSaveOptions = null optionalposition: 1
Optional CSV save options.
leaveOpen System.Boolean = false optionalposition: 2
Whether to leave the destination writer open when this writer is disposed.

Methods

public virtual Void Dispose() #
Returns: Void
WriteDataReader 2 overloads
public Void WriteDataReader(IDataReader reader) #
Returns: Void

Writes all rows from an IDataReader using the reader field names as CSV columns.

Parameters

reader System.Data.IDataReader requiredposition: 0
Source data reader positioned before the first row.
public Void WriteDataReader(IDataReader reader, CancellationToken cancellationToken) #
Returns: Void

Writes all rows from an IDataReader using the reader field names as CSV columns.

Parameters

reader System.Data.IDataReader requiredposition: 0
Source data reader positioned before the first row.
cancellationToken System.Threading.CancellationToken requiredposition: 1
Token observed while projecting and writing rows.
public Void WriteObject(Object item) #
Returns: Void

Writes one object row, inferring columns from the first row.

Parameters

item System.Object requiredposition: 0
Object, dictionary, or flattened row to write.
WriteRow 3 overloads
public Void WriteRow(IReadOnlyList<String> columns, IReadOnlyList<Object> values) #
Returns: Void

Writes one already-projected row using the provided column order.

Parameters

columns System.Collections.Generic.IReadOnlyList{System.String} requiredposition: 0
Column names for the first row and validation for later rows.
values System.Collections.Generic.IReadOnlyList{System.Object} requiredposition: 1
Values in the same order as columns.
public Void WriteRow(IReadOnlyList<String> columns, Object[] values) #
Returns: Void

Writes one already-projected row using the provided column order.

Parameters

columns System.Collections.Generic.IReadOnlyList{System.String} requiredposition: 0
Column names for the first row and validation for later rows.
values System.Object[] requiredposition: 1
Values in the same order as columns.
public Void WriteRow(Object[] values) #
Returns: Void

Writes one already-projected row using the column order that was established by a previous row.

Parameters

values System.Object[] requiredposition: 0
Values in the same order as the established CSV columns.
public Void WriteRows(IReadOnlyList<String> columns, IEnumerable<Object[]> rows) #
Returns: Void

Writes already-projected rows using one shared column order.

Parameters

columns System.Collections.Generic.IReadOnlyList{System.String} requiredposition: 0
Column names shared by every row.
rows System.Collections.Generic.IEnumerable{System.Object[]} requiredposition: 1
Rows whose values use the same order as columns.
WriteRow``1 2 overloads
public Void WriteRow<TState>(Int32 valueCount, TState state, Func<TState, Int32, Object> valueAccessor) #
Returns: Void

Writes 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 requiredposition: 0
Number of values exposed by valueAccessor.
state ``0 requiredposition: 1
Caller state passed to valueAccessor for each column index.
valueAccessor System.Func{``0,System.Int32,System.Object} requiredposition: 2
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) #
Returns: Void

Writes 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} requiredposition: 0
Column names for the first row and validation for later rows.
valueCount System.Int32 requiredposition: 1
Number of values exposed by valueAccessor.
state ``0 requiredposition: 2
Caller state passed to valueAccessor for each column index.
valueAccessor System.Func{``0,System.Int32,System.Object} requiredposition: 3
Function that returns the value for a column index.
WriteTextRow 2 overloads
public Void WriteTextRow(IReadOnlyList<String> columns, String[] values) #
Returns: Void

Writes one already-formatted text row using the provided column order.

Parameters

columns System.Collections.Generic.IReadOnlyList{System.String} requiredposition: 0
Column names for the first row and validation for later rows.
values System.String[] requiredposition: 1
Text values in the same order as columns.
public Void WriteTextRow(String[] values) #
Returns: Void

Writes one already-formatted text row using the column order that was established by a previous row.

Parameters

values System.String[] requiredposition: 0
Text values in the same order as the established CSV columns.
public Void WriteTextRows(IReadOnlyList<String> columns, IEnumerable<String[]> rows) #
Returns: Void

Writes already-formatted text rows using one shared column order.

Parameters

columns System.Collections.Generic.IReadOnlyList{System.String} requiredposition: 0
Column names shared by every row.
rows System.Collections.Generic.IEnumerable{System.String[]} requiredposition: 1
Text rows whose values use the same order as columns.
WriteTextRow``1 2 overloads
public Void WriteTextRow<TState>(IReadOnlyList<String> columns, Int32 valueCount, TState state, Func<TState, Int32, String> valueAccessor) #
Returns: Void

Writes 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} requiredposition: 0
Column names for the first row and validation for later rows.
valueCount System.Int32 requiredposition: 1
Number of values exposed by valueAccessor.
state ``0 requiredposition: 2
Caller state passed to valueAccessor for each column index.
valueAccessor System.Func{``0,System.Int32,System.String} requiredposition: 3
Function that returns the already-formatted text for a column index.
public Void WriteTextRow<TState>(Int32 valueCount, TState state, Func<TState, Int32, String> valueAccessor) #
Returns: Void

Writes 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 requiredposition: 0
Number of values exposed by valueAccessor.
state ``0 requiredposition: 1
Caller state passed to valueAccessor for each column index.
valueAccessor System.Func{``0,System.Int32,System.String} requiredposition: 2
Function that returns the already-formatted text for a column index.

Properties

public Boolean HasRows { get; } #

Gets whether at least one row was written.