docs.sheetjs.com/docz/docs/03-demos/06-data/03-indexeddb.md
2023-02-24 02:55:41 -05:00

828 B

title pagination_prev pagination_next sidebar_custom_props
IndexedDB API demos/grid demos/worker
type
web

:::warning

IndexedDB is a very low-level API. It is strongly recommended to use a wrapper library or WebSQL in production applications.

:::

localForage is a IndexedDB wrapper that presents an async Storage interface.

Arrays of objects can be stored using JSON.stringify using row index as key:

const aoo = XLSX.utils.sheet_to_json(ws);
for(var i = 0; i < aoo.length; ++i) await localForage.setItem(i, JSON.stringify(aoo[i]));

Recovering the array of objects is possible by using JSON.parse:

const aoo = [];
for(var i = 0; i < localForage.length; ++i) aoo.push(JSON.parse(await localForage.getItem(i)));
const wb = XLSX.utils.json_to_sheet(aoo);