Skip to content

JSON Export

Mats Alm edited this page Nov 7, 2023 · 16 revisions

EPPlus 6 provides a new functionality to export JSON directly from a range or a table. The .NET datatypes from EPPlus will be translated to a more generic format and both the raw value and the formatted value from the cells will be included. JSON export for ranges and table looks slightly different as tables contains a more structured format.

Sample

JsonExport1

Json export can be used for many purposes, one example is to export spreadsheet data to a front end ui library. See our sample site.

Datatypes

See the table below for how .NET datatypes are mapped to the export.

.NET data type JSON datatype name Comment
bool boolean Exported as 1/0
Byte, Sbyte, UInt16, UInt32, UInt64, Int16, Int32, Int64, Decimal, Double, Single (float) number All types mapped to the single number datatype
DateTime datetime Exported to milliseconds before/after January 1, 1970 (Unix time).
TimeSpan timespan Exported as a numeric value, total milliseconds after midnight.
string (and all other datatypes) string Exported as-is

Datatypes are exported in the field dt (see examples below) and is either present on the column or the cell level.

Examples of exported elements

Numeric cell value

Note that in this sample the formatted value (t) uses a comma as decimal separator, however the raw value (v) always uses a dot.

{
   "v": "10.35",
   "t": "10,35"
}