CSV is read and written by CsvIO (unvell.ReoGrid.Core.IO), following RFC 4180.

Reading and writing

// reading - the start position and the delimiter are yours to choose
CsvIO.Read(ws, File.ReadAllText("data.csv"));
CsvIO.Read(ws, File.ReadAllText("tsv.txt"), startRow: 0, startCol: 0, delimiter: '\t');

// writing - the used range is what gets written
File.WriteAllText("out.csv", CsvIO.Write(ws));

Read writes into an existing sheet; it does not build a workbook. startRow / startCol move where it writes, so several CSV files can be laid out on one sheet.

Write covers the used range. An empty sheet gives back an empty string.

Delimiter

Pass a tab as delimiter to handle TSV. The default is a comma.

How values are interpreted

Only numbers and booleans are interpreted when a field is read. Unlike Cell Editing, dates, % and formulas are not.

InputResult
1234a number
TRUE / FALSEa boolean
2026/07/28text
=SUM(A1:A2)text
anything elsetext

To have a field treated as a formula or a date, set that cell again after loading, with SetFormula and the like.

Quoting and escaping

Per RFC 4180.

  • A field containing the delimiter, a newline or a quote is wrapped in "
  • A " inside a field is doubled as ""

Writing escapes by the same rules.

What is not saved

CSV is a values-only format. Styles, number formats, merges, borders and cell types are not saved. Write emits the display text — the string with its number format applied, and a formula cell writes out its result.

Encoding

CsvIO deals in strings, so encoding is the caller’s responsibility. When the file is meant to be opened in Excel, write UTF-8 with a BOM.

File.WriteAllText("out.csv", CsvIO.Write(ws), new UTF8Encoding(true));

Not the same as the clipboard

The TSV used for pasting is RangeClipboard.BuildTsv(...). It takes a range and is paired with style-carrying HTML (Clipboard).

Was this article helpful?