[フレーム]
 []
 
MESCIUS Logo MESCIUS Logo
SpreadJS Logo
DEMOS DOC DESIGNER API
DOWNLOAD
(Showing Draft Content)

Import and Export JSON

You can import data from or export data to a JSON object using the fromJSON method and toJSON method.

While importing data from a JSON object, you can set several deserialization options for custom data import. These options include ignoreStyle, ignoreFormula, frozenColumnsAsRowHeaders, frozenRowsAsColumnHeaders and doNotRecalculateAfterLoad.

While exporting data to a JSON object, you can set several serialization options for exporting custom data. These options include includeBindingSource, ignoreStyle, ignoreFormula, saveAsView, rowHeadersAsFrozenColumns, columnHeadersAsFrozenRows, includeAutoMergedCells, and saveR1C1Formula.

Note: Earlier versions of SpreadJS cannot load JSON files created with SpreadJS 3.20142.11 or later.

The following code sample shows how to export to and import from a JSON object.

workbook.fromJSON(jsonData,{
ignoreFormula:true,
ignoreStyle:true,
frozenColumnsAsRowHeaders:false,
frozenRowsAsColumnHeaders:false,
doNotRecalculateAfterLoad:true
});
workbook.toJSON({
includeBindingSource:true, 
ignoreFormula:true,
ignoreStyle:true,
saveAsView:true,
rowHeadersAsFrozenColumns:true,
columnHeadersAsFrozenRows:true
includeAutoMergedCells:true,
saveR1C1Formula:true
});

The following Visual Code sample loads an ssjson file.

<?xml version="1.0"?>
<!--
 For more information on how to configure your ASP.NET application, visit http://go.microsoft.com/fwlink/?LinkId=169433
 -->
<configuration>
 <system.web>
 <compilation debug="true" targetFramework="4.5" />
 <httpRuntime targetFramework="4.5" />
 </system.web>
 <system.webServer>
 <staticContent>
 <mimeMap fileExtension=".ssjson" mimeType="text/plain" />
 </staticContent>
 </system.webServer>
</configuration>
<!DOCTYPE html>
<html lang="en">
<head>
 <title>TestLoad ssjson</title>
 <!--SpreadJS Widgets CSS-->
 <link href="./css/gc.spread.sheets.x.x.x.css" rel="stylesheet" type="text/css" />
 
 <!--jQuery Reference-->
 <script src="http://code.jquery.com/jquery-1.9.1.min.js" type="text/javascript"></script> 
 <!--SpreadJS Widgets JavaScript-->
 <script src="./scripts/gc.spread.sheets.all.x.x.x.min.js" type="text/javascript"></script>
 <script type="text/javascript">
 $(document).ready(function () { 
 var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"),{sheetCount:3});
 $.ajax({
 url: "TestFile.ssjson",
 datatype: "json",
 success: function (data) {
 //here to load ssjson file.
 spread.suspendPaint();
 spread.fromJSON(JSON.parse(data));
 spread.resumePaint();
 },
 error: function (ex) {
 alert('Exception:' + ex);
 }
 });
 });
 </script>
</head>
<body>
 <div class="container">
 <div class="header">
 <h2>Sample for load .ssjson file</h2>
 </div>
 <div id="ss" style="width: 100%; height: 430px; border: 1px solid gray;"></div>
 </div>
</body>
</html>

AltStyle によって変換されたページ (->オリジナル) /