API Reference

Class

CsvObjectWriter

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

Streams object rows to CSV without materializing a CsvDocument.

Inheritance

  • Object
  • CsvObjectWriter

Constructors

public CsvObjectWriter(TextWriter writer, CsvSaveOptions options = null, Boolean leaveOpen = false) #

Initializes a streaming object 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
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 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 2 overloads
public Void WriteRow<TState>(IReadOnlyList<String> columns, Int32 valueCount, TState state, Func<TState, Int32, Object> valueAccessor) #
Returns: Void

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

Type Parameters

TState

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.
WriteRow(System.Collections.Generic.IReadOnlyList{System.String} columns, System.Object[] values) #

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

Parameters

columns System.Collections.Generic.IReadOnlyList{System.String} required
Column names for the first row and validation for later rows.
values System.Object[] required
Values in the same order as columns.
WriteRow``1(System.Collections.Generic.IReadOnlyList{System.String} columns, System.Int32 valueCount, ``0 state, System.Func{``0,System.Int32,System.Object} valueAccessor) #

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} required
Column names for the first row and validation for later rows.
valueCount System.Int32 required
Number of values exposed by valueAccessor.
state ``0 required
Caller state passed to valueAccessor for each column index.
valueAccessor System.Func{``0,System.Int32,System.Object} required
Function that returns the value for a column index.
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 the provided column order.

Type Parameters

TState

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.
WriteTextRow``1(System.Collections.Generic.IReadOnlyList{System.String} columns, System.Int32 valueCount, ``0 state, System.Func{``0,System.Int32,System.String} valueAccessor) #

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

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

Type Parameters

TState

Parameters

values System.Object[] requiredposition: 0
Values in the same order as the established CSV columns.
WriteTrustedRow``1(System.Int32 valueCount, ``0 state, System.Func{``0,System.Int32,System.Object} valueAccessor) #

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 required
Number of values exposed by valueAccessor.
state ``0 required
Caller state passed to valueAccessor for each column index.
valueAccessor System.Func{``0,System.Int32,System.Object} required
Function that returns the value for a column index.
public Void WriteTrustedTextRow<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

Parameters

values System.String[] requiredposition: 0
Text values in the same order as the established CSV columns.
WriteTrustedTextRow``1(System.Int32 valueCount, ``0 state, System.Func{``0,System.Int32,System.String} valueAccessor) #

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

Properties

public Boolean HasRows { get; } #

Gets whether at least one row was written.