Hello,
For the Server Side Import Export, please have a look at codes below:-
If the Excel is on server, it’s possible to open it directly. But if the file is local file then the browser cannot open local file without dialog.
For opening server file, you can use Server side ExcelIO, or download file then open it by client side ExcelIO.
[csharp] // Download Excel file
var excelFilePath = ‘http://path/template.xlsx’;
var xhr = new XMLHttpRequest();
xhr.open(‘GET’, excelFilePath, true);
xhr.responseType = ‘blob’;
xhr.onload = function(e) {
if (this.status == 200) {
// get binary data as a response
var blob = this.response;
// convert Excel to JSON
excelIo.open(blob, function (json) {
var workbookObj = json;
spread.fromJSON(workbookObj);
}, function (e) {
// process error
alert(e.errorMessage);
}, {});
}
};
xhr.send();[/csharp]
In order to save the modified JSON file into the server as Excel. You Upload the exported blob object to server which is already an excel file. In server we have a “saveExport” API or hander to get excel stream, then you can save it:-
[csharp]/form>
function exportData(){
var json = spread.toJSON({includeBindingSource: true});
var excelIo = new GC.Spread.Excel.IO();
// here is excel IO API
excelIo.save(json, function (blob) {
var fd = new FormData(document.forms.namedItem(“myform”));
fd.append(“test.xlsx”,blob);
// you can insert your code to save it to SSJSON
$.ajax({
url: "saveExport",
type:"POST",
contentType:false,
processData: false,
data:fd,
success: function (data) {
if(data.isSuccess == 1){
alert("Success!");
}else{
alert(data.errorMessage);
}
},
error: function (ex) {
alert("Error:"+ex);
}
});
}, function (e) {
alert(e);
});
}[/csharp]
Hope it helps.
Thanks,
Reeva