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 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.

Properties

public Boolean HasRows { get; } #

Gets whether at least one row was written.