- SpreadJS Overview
- Getting Started
- JavaScript Frameworks
- Best Practices
-
Features
- Workbook
- Worksheet
- Rows and Columns
- Headers
- Cells
- Data Binding
- TableSheet
- GanttSheet
- ReportSheet
- Data Charts
- JSON Schema with SpreadJS
- SpreadJS File Format
- Data Validation
- Conditional Formatting
- Sort
- Group
- Formulas
- Serialization
- Keyboard Actions
- Shapes
- Floating Objects
- Barcodes
- Charts
- Sparklines
- Tables
- Pivot Table
- Slicer
- Theme
- Culture
- AI Assistant
- SpreadJS Designer
- SpreadJS Designer Component
- SpreadJS Collaboration Server
- Touch Support
- Formula Reference
- Import and Export Reference
- Frequently Used Events
- API Documentation
- Release Notes
TableSheet IO
You can export a TableSheet in various formats such as JSON, Excel, PDF, and even print it just like printing a spreadsheet.
JSON Serialization
TableSheet JSON serialization and deserialization are done using the workbook's toJSON and fromJSON methods.
function saveJSON() {
// Save JSON
var json = spread.toJSON({ includeBindingSource: true, saveAsView: true });
saveAs(new Blob([JSON.stringify(json)], { type: "text/plain;charset=utf-8" }), 'exportedJSON.ssjson');
}
function openJSON() {
// Load JSON
var file = document.getElementById("fileDemo").files[0];
if (file) {
var reader = new FileReader();
reader.onload = function () {
var json = JSON.parse(this.result);
spread.fromJSON(json);
};
reader.readAsText(file);
}
}Export Excel Files
Exporting tablesheet to Excel is done using the GC.Spread.Sheets save method. TableSheet is treated as a table in a worksheet and includes alternatingRowStyles and conditional format results when saveAsView is true and excludes icon set, data bar, and data validation.
It is necessary to set includeBindingSource to true when exporting to Excel. It is optional to set saveAsView to true when exporting to Excel.
function saveExcel() {
// Save Excel
spread.save(function (blob) {
// save blob to a file
saveAs(blob, fileName);
}, function (e) {
console.log(e);
}, { includeBindingSource: true, saveAsView: true }
);
}Export PDF
Exporting tablesheet to PDF is done using the workbook's savePDF method. PDF includes binding results and excludes icons, options, and actionColumn.
For printing or exporting to PDF, users can customize the print information using the printInfo method.
function savePDF() {
// Save PDF
spread.savePDF(function (blob) {
saveAs(blob, "exportedPDF.pdf");
}, function (error) {
console.log(error);
}, null, spread.getSheetCount() + spread.getActiveSheetTabIndex());
}Print Tablesheet
TableSheet printing is done using the workbook's print method. Print includes binding results and excludes icons, options, and actionColumn.
function print() {
// Print Spread
spread.print();
}