o-spreadsheet
o-spreadsheet copied to clipboard
Can extract data from the sheet
hi, I found this lib is very useful. am looking for a library where we can store and retrieve the data from the sheet is this possible with this library,i am not able to see anything relevant extract data from the sheet and store in DB
Hello @ramusesan Are you looking for a way to save the state of the sheet and store it in a DB? With the goal to re-open the spreadsheet later with the data? Did I understand correctly ?
If that's what you are looking for, you can use the exportData()
method on the model. The spreadsheet state is a json data structure.
const model = new Model(...);
// when you want to retrieve the spreadsheet data
const data = model.exportData();
// now you can do whatever you want with the data, including saving it to a database
Without any update for two months, I will close this issue.
Regards
Hello @ramusesan Are you looking for a way to save the state of the sheet and store it in a DB? With the goal to re-open the spreadsheet later with the data? Did I understand correctly ?
If that's what you are looking for, you can use the
exportData()
method on the model. The spreadsheet state is a json data structure.const model = new Model(...); // when you want to retrieve the spreadsheet data const data = model.exportData(); // now you can do whatever you want with the data, including saving it to a database
I tried this but I cannot get the data from Cells which has formula in it
Do you mean you don't get the cell values (evaluated formulas)?
Do you mean you don't get the cell values (evaluated formulas)?
That is exactly what I wanted evaluated(or should I say computed ?) values . so I can put that in my db
I tried model.getters.getCell("Sheet1",1,12)
I am getting the formula but evaluated object shows value "Loading..."
Do you mean you don't get the cell values (evaluated formulas)?
That is exactly what I wanted evaluated(or should I say computed ?) values . so I can put that in my db I tried
model.getters.getCell("Sheet1",1,12)
I am getting the formula but evaluated object shows value "Loading..."
Update :
I just set my model mode from headless to normal and it worked but only for one sheet while the evaluated data in other sheets shows 'Loading'
const model = await new Model(data, {
mode: "normal",
});
Update 2:
I need to evaluate Cells in loop and it worked
var sheets = model.getters.getSheets()
for (let index = 0; index < sheets.length; index++) {
await model.dispatch("EVALUATE_CELLS", { sheetId: sheets[index].id})
}
Which version are you using ? (I strongly suggest using 16.0 or the latest 16.3)