Method FromCsv
- Namespace
- DocWright.Spreadsheet
- Assembly
- DocWright.Spreadsheet.dll
FromCsv(TextReader, XlsxCsvReadOptions?)
Makes a workbook of one sheet from delimited text (CSV).
public static XlsxDocument FromCsv(TextReader reader, XlsxCsvReadOptions? options = null)
Parameters
readerTextReaderThe text. It is read to its end and not closed.
optionsXlsxCsvReadOptionsHow to read, or null for the defaults: a comma, a double quote, every field text.
Returns
- XlsxDocument
A workbook as Create(XlsxCreateSettings?) starts one, its sheet holding the fields from A1.
Remarks
RFC 4180 as applications write it: a field may be quoted, a quote inside a quoted field is doubled, a quoted field may hold the delimiter and line breaks, and a row ends in a carriage return and a line feed, a line feed or a carriage return. A byte order mark at the start is skipped. An empty field fills no cell; an empty line is an empty row. Rows need not be of one length.
Every field becomes text unless InferTypes asks
otherwise, so nothing is lost or guessed: 007 stays 007, and a field
that begins with = is text, never a formula.
The text is somebody else's: a field longer than a cell holds (32,767 characters), more columns or rows than a worksheet has, and a quote that is never closed are refused; so is more than MaxCells cells.
Exceptions
- ArgumentNullException
readeris null.- ArgumentException
The delimiter or the quote is a line break, the two are the same, or the sheet name is not one Excel accepts.
- InvalidDocumentException
The text cannot be put on a worksheet: see the remarks.
- ResourceLimitExceededException
The text fills more cells than MaxCells.