Posted 5 April 2020, 11:23 pm EST
Hi Vinayak,
SpreadJS is a pure client-side library and it is not opinionated about the type of backend/techniques you use.to save files. So to save/restore JSON all you need to do is use the toJSON() method to get the JSON of the workbook and fromJSON(_) method to load the saved JSON. You may refer to the following code snippet:
// save json
// get json
let wbJSON = spreadInstance.toJSON();
// send wbJSON to server to save to file, you may use fetch API or angular's HttpClient according to your project's requirement
// you may use the JSON.strigify method if the server expects a json string
this.httpClient.post("url_to_send_data", wbJSON).subscribe(() => {
alert("uploaded to server");
});
// load json from server
// get json from server, user fetchAPI or HttpClient
this.httpClient.get("url").subscribe(data => {
// let receivedJSON = data;
// use json.parse if backend returns json string
// load json into spread
spreadInstance.fromJSON(receivedJSON);
});
Regards
Sharad