Posted 6 January 2020, 7:38 am EST
Hi Team,
I have a requirement to save the flexsheet to DB and retrieve it when the user needs it. It worked fine with JsZip 2.5 but after upgrading to jsZip 3.1, isnipte of modifying all the methods, I’m unable to load the saved sheet back from DB.Below is a snippet of the code used before and after JsZip upgrade.
with jszip 2.5V
saveSheetToDB(){
var zip = new JSZip();
/// serialize sheet_data.
zip.file(“sheet_data”, JSON.stringify(records));
/// c. serialize sheet. zip.file("sheet", vm.get("sheet").save().save()); var zip_data = zip.generate({ type: "uint8array" });
ajax call to save zip_data to DB
}
loadSheetFromDB{
ajax call to DB
var zip_obj= new JSZip();
zip_obj.load(response.responseBytes);
var data=JSON.parse(zip_obj.file(“sheet_data”).asText())
/// load wijmo sheet. var base64 = zip_obj.file("sheet").asText(); sheet = new wijmo.grid.sheet.FlexSheet("#id")); /// load workbook. sheet.load(base64);
}
with jszip 3.1.5V
saveSheetToDB(){
var zip = new JSZip();
/// serialize sheet_data.
zip.file(“sheet_data”, JSON.stringify(records));
/// c. serialize sheet. zip.file("sheet", vm.get("sheet").saveAsync().saveAsync()); var zip_data = zip.generateAsync({ type: "uint8array" }).then(function (zip_data){
ajax call to save zip_data to DB
}
});
}
loadSheetFromDB{
ajax call to DB
var zip1= new JSZip();
zip1.loadAsync(response.responseBytes).then(function(zip_obj){
zip_obj.file(“sheet_data”).async(“string”)
.then(function (data) {
/// load wijmo sheet. zip_obj.file("sheet").async("string") .then(function (base64) { var sheet = new wijmo.grid.sheet.FlexSheet("#id")); /// load workbook. sheet.loadAsync(base64);
});
});
});
}
But the zip_obj.file(“sheet”).async(“string”) method doesn’t return any data. whereas when i look into zip_obj I see that it has a definition for “sheet” as a file. Could you please help me in identifying the problem here.
Thanks,
Keerthana