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.
Afficher le fichier Open project: Kajabity/Kajabity-Tools Class Usage Examples

Méthodes publiques

Свойство Type Description
QuoteLimit int

Méthodes publiques

Méthode 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

Méthode 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 méthode

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.
Résultat System.IO

WriteAll() public méthode

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.
Résultat void

WriteField() public méthode

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
Résultat void

WriteRecord() public méthode

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.
Résultat 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
Résultat int