Import and Export JSON Stream

Spread.Services Documentation
Import and Export JSON Stream
Collapse All Expand All

Spread.Services Documentation > Developer's Guide > Manage Data in Spread Component > Import and Export JSON Stream

The sole purpose of facilitating users in importing and exporting to and from json stream is to enable them to exchange and organize object data as and when required. This reference summarizes how Spread.Services handles the import and export of json stream using .Net core.

You can export a workbook to a json string/stream using the ToJson method of the IWorkbook interface. You can also import a json string or stream to your workbook using the FromJson method of the IWorkbook interface.

Refer to the following example code to import and export json stream.

C# | Copy Code
--- | ---

    //ToJson&FromJson can be used in combination with spread.sheets product

    //spread.services import an excel file.
    //change the path to real source file path.
    string source = "savingfile.xlsx";
    workbook.Open(source);

    //spread.services export to a json string.
    var jsonstr = workbook.ToJson();
    //use the json string to initialize spread.sheets product.
    //spread.sheets will show the excel file contents.

    //spread.sheets product export a json string.
    //spread.services use the json string to initialize.
    workbook.FromJson(jsonstr);
    //spread.services export workbook to an excel file.
    //change the path to real export file path.

    string export = "export.xlsx";
    workbook.Save(export);

Copyright © GrapeCity, inc. All rights reserved.