Available for: UI for ASP.NET MVC | UI for ASP.NET AJAX | UI for Blazor | UI for WPF | UI for WinForms | UI for Silverlight | UI for Xamarin | UI for WinUI | UI for ASP.NET Core | UI for .NET MAUI

New to Telerik Document Processing? Download free 30-day trial

JsonExportSettings

The JsonFormatProvider exposes an ExportSettings property of type JsonExportSettings. The settings control the behavior of the JsonFormatProvider when exporting a Workbook to JSON. By adjusting the available properties you can tailor the size, richness and focus of the generated JSON payload.

Properties

Property Type Default Description
ExportWhat ExportWhat EntireWorkbook Portion of the workbook to export (entire workbook, active sheet, or selection).
IncludeHiddenSheets bool false Include hidden worksheets when exporting the entire workbook.
IncludeDefinedNames bool true Export defined names (named ranges / constants).
IncludeNumberFormats bool true Emit number format codes for formatted cells.
IncludeCharts bool true Serialize chart objects from exported sheets.
ChartDataMode ChartDataMode ReferencesOnly Control chart data representation: only reference formulas, only resolved literal values, or both.
PrettyPrint bool false Indent JSON output for readability. Disable to reduce size.
ValueRenderMode ValueRenderMode Display Export raw underlying values, formatted display values, or both.
IncludeBlankCells bool false Emit blank cells explicitly within the used range; otherwise they are skipped.
IncludeWorkbookProtectionFlag bool true Include workbook protection state (Workbook.IsProtected).
IncludeActiveSheet bool true Emit the name of the active worksheet in metadata.
SelectedRanges List empty Ranges to export when ExportWhat is Selection. Empty collection falls back to active sheet.
IncludeChartStats bool true Include min, max, average, sum, stdev and count aggregates for chart series.
IncludeChartSummaries bool true Include natural language summary strings per chart.
IncludeChartTrends bool true Include simple trend classification (increasing / decreasing / flat) for eligible series.

Enum Values

ExportWhat

  • ActiveSheet - Exports only the currently active worksheet.
  • EntireWorkbook - Exports all worksheets in the workbook. (Default)
  • Selection - Exports only the currently selected cell ranges.

ChartDataMode

  • ReferencesOnly - Only formula / reference expressions are exported. (Default)
  • ResolvedValues - Only resolved literal value arrays are exported.
  • Both - Both references and resolved value arrays are exported.

ValueRenderMode

  • Raw - Underlying raw cell value is exported.
  • Display - Formatted display value is exported. (Default)
  • Both - Both raw and display representations are exported.

Basic Usage

The following example shows how you can create a JsonExportSettings instance with the desired settings while exporting a Workbook to JSON format:

Workbook workbook;
XlsxFormatProvider xlsxFormatProvider = new XlsxFormatProvider();

using (Stream input = new FileStream("inputFile.xlsx", FileMode.Open))
{
    workbook = xlsxFormatProvider.Import(input, TimeSpan.FromSeconds(10));
}

string jsonOutputPath = "outputFile.json";
JsonFormatProvider jsonFormatProvider = new JsonFormatProvider();

JsonExportSettings jsonExportSettings = new JsonExportSettings
{
    ExportWhat = ExportWhat.EntireWorkbook,
    IncludeWorkbookProtectionFlag = true,
    IncludeNumberFormats = true,
    IncludeActiveSheet = true,
    IncludeBlankCells = true,
    ValueRenderMode = ValueRenderMode.Raw,
    PrettyPrint = true,
    IncludeHiddenSheets = true,
    ChartDataMode = ChartDataMode.ReferencesOnly,
    IncludeCharts = true,
    IncludeChartStats = true,
    IncludeChartSummaries = true,
    IncludeChartTrends = true,
    IncludeDefinedNames = true
};

jsonFormatProvider.ExportSettings = jsonExportSettings;

using (Stream output = new FileStream(jsonOutputPath, FileMode.Create))
{
    jsonFormatProvider.Export(workbook, output, TimeSpan.FromSeconds(10));
}

See Also

In this article