The first step to work with SpreadJS is to add a workbook object to the web page and get an instance variable through which you can customize all aspects of the control and dynamically change the contents of the loaded workbook with JavaScript code.
You can add a SpreadJS workbook to a web page using the following steps:
<!DOCTYPE html>
<html>
<head>
<link href='gc.spread.sheets.x.x.x.css' rel='stylesheet' type='text/css'/>
<script src='gc.spread.sheets.all.x.x.x.min.js' type='text/javascript'></script>
<script type='text/javascript' charset='utf-8'>
...
</script>
</head>
<body>
<div id='ss' style='width:100%; height:400px;'></div>
</body>
</html>
Once the object is created, you can use the workbook variable to load a SpreadJS SSJSON file, import an Excel file, change the visible elements of the control like the scrollbars, tabstrip, formula box, and dynamically modify the workbook's sheets, tables, and charts, etc. The other feature demos will demonstrate many of these properties.
Finally, you can also access any workbook on the page using the GC.Spread.Sheets.findControl method and provide it with a DOM element on the page that hosts a workbook.
window.onload = function () {
// Initialize a workbook
var workbook = new GC.Spread.Sheets.Workbook(document.getElementById('ss'), { sheetCount: 1 });
// var workbook = new GC.Spread.Sheets.Workbook('ss', { sheetCount: 1 });
// get workbook object
// var workbook = GC.Spread.Sheets.findControl(document.getElementById('ss'));
};
If you use JQuery, instantiate the workbook as follows:
$(document).ready(function () {
// Initialize a workbook
var workbook = new GC.Spread.Sheets.Workbook($('#ss')[0], { sheetCount: 1 });
// get spread Workbook object
// var workbook = $('#ss').data('workbook');
});
Submit and view feedback for