Our DevChannel delivers pre-release previews of next version builds and hot fixes. The first entry is a preview build of v10 which is due to release in November. This build has an early version of the new client-side ExcelIO feature. You can now implement Excel import and export functionality on the client and you no longer need to implement the .NET server component. This makes Spread.Sheets applications much easier to distribute and removes dependencies on IIS. Keep in mind that this is a very early preview and many Excel features are not yet supported. We have a special DevChannel forum in which you can discuss any problems you may be having. Visit the DevChannel to download this build or keep reading for more information.
About the v10 Preview Download
The preview download is a .ZIP file containing Spread.Sheets JavaScript, CSS, and samples. You will not find to the ExcelIO server component or the SpreadJS designer. Please download the latest SpreadJS release to get those items. It is intended for preview, so please don't use it in production environments.
How to Preview the New ExcelIO Feature
The best way to preview the new feature is to find the ExcelIO sample (found in /scripts/samples). You can test the UI there or view the source to see how the feature is implemented. The basic steps follow: Add these JavaScript modules to your application:
- FileSaverJS - found at https://github.com/eligrey/FileSaver.js/
- Spread.Sheets core - found in /scripts
- ExcelIO - found in /interop
<script src="external/FileSaver.js"></script><script src="../../../scripts/gc.spread.sheets.all.10.40.20162.0.js"></script>
<script src="../../../scripts/interop/gc.spread.excelio.10.40.20162.0.js"></script>
Initialize the workbook and excel IO instance.
var workbook = new GC.Spread.Sheets.Workbook(document.getElementById("ss"));
var excelIo = new GC.Spread.Excel.IO();
Add buttons for import and export functions.
Bind events to your buttons.
$("#loadExcel").click(function () {
var excelFile = document.getElementById("fileDemo").files[0];
// here is excel IO API
excelIo.open(excelFile, function (json) {
var workbookObj = JSON.parse(json);
workbook.fromJSON(workbookObj);
}, function (e) {
// process error
console.log(e);
});
});
$("#saveExcel").click(function () {
var fileName = $("#exportFileName").val();
if (fileName.substr(-5, 5) !== '.xlsx') {
fileName += '.xlsx';
}
var json = JSON.stringify(workbook.toJSON());
// here is excel IO API
excelIo.save(json, function (blob) {
saveAs(blob, fileName);
}, function (e) {
// process error
console.log(e);
});
});