C# Class Kajabity.Tools.Csv.CsvWriter

A class for writing a table of data to an output stream using the Comma Separated Value (CSV) format.
Mostrar archivo Open project: Kajabity/Kajabity-Tools Class Usage Examples

Public Properties

Property Type Description
QuoteLimit int

Public Methods

Method Description
CsvWriter ( Stream stream ) : System.IO

Construct a new to output CSV data to the stream provided.

WriteAll ( string records ) : void

Write all records to the output CSV stream.

WriteField ( string field ) : void

Write a single field to the output stream appending a separator if it is not the first field on the line.

WriteRecord ( string record ) : void

Writes a single record to the output stream appending a new line to the end of the previous line if this is not the first record.

Private Methods

Method Description
WriteFieldEscaped ( string field ) : void

This is the worker method that writes fields to the file and quotes them if necessary. If the field is null or an empty string, nothing is written (not even quoted).

Method Details

CsvWriter() public method

Construct a new to output CSV data to the stream provided.
public CsvWriter ( Stream stream ) : System.IO
stream System.IO.Stream CSV data will be written to this stream.
return System.IO

WriteAll() public method

Write all records to the output CSV stream.
public WriteAll ( string records ) : void
records string an array of string arrays containing the /// records to be written. Each string becomes a single comma separated /// field, each array of strings becomes a record.
return void

WriteField() public method

Write a single field to the output stream appending a separator if it is not the first field on the line.
public WriteField ( string field ) : void
field string
return void

WriteRecord() public method

Writes a single record to the output stream appending a new line to the end of the previous line if this is not the first record.
public WriteRecord ( string record ) : void
record string The record to be written - an array of string fields.
return void

Property Details

QuoteLimit public_oe property

The class checks each field to see if it needs to be quoted - unless the string is longer than quoteLimit. Used for performance. Set to 0 to ensure all except empty or null fields are quoted.
public int QuoteLimit
return int