C# Класс Kajabity.Tools.Csv.CsvWriter

A class for writing a table of data to an output stream using the Comma Separated Value (CSV) format.
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
QuoteLimit int

Открытые методы

Метод Описание
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.

Приватные методы

Метод Описание
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).

Описание методов

CsvWriter() публичный Метод

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.
Результат System.IO

WriteAll() публичный Метод

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.
Результат void

WriteField() публичный Метод

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
Результат void

WriteRecord() публичный Метод

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.
Результат void

Описание свойств

QuoteLimit публичное свойство

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
Результат int