<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>SheetJS Firebase Dump Demo</title><style>a { text-decoration: none }</style></head><body><pre><h3><a href="//sheetjs.com/">SheetJS</a> Firebase Dump Demo</h3><b>Example Code</b>
/* ... connect to firebase */ const database = firebase.database();
/* import workbook */ await database.ref('foo').set(workbook);
/* change cells */ database.ref('foo').update({ "Sheets/Sheet1/A1": {"t": "s", "v": "J"}, "Sheets/Sheet1/A2": {"t": "n", "v": 5}, });
/* export snapshot */ const val = await database.ref('foo').once('value').val(); XLSX.writeFile(wb, "firebase.xlsx");
</pre><script src="xlsx.full.min.js"></script><script src="https://www.gstatic.com/firebasejs/4.12.0/firebase.js"></script><script>const Firebase = firebase;const config = { credential: { getAccessToken: () => ({ expires_in: 0, access_token: '', }), }, databaseURL: 'ws://localhost:5555'};
const wb = XLSX.read('a,b,c\n1,2,3', {type:"binary"});
let P = Promise.resolve("sheetjs");
P = P.then(async () => { Firebase.initializeApp(config); const database = Firebase.database(); await database.ref('foo').set(null); return [database];});
P = P.then(async ([database]) => { await database.ref('foo').set(wb); return [database];});
P = P.then(async ([database]) => { database.ref('foo').update({ "Sheets/Sheet1/A1": {"t": "s", "v": "J"}, "Sheets/Sheet1/A2": {"t": "n", "v": 5}, }); return [database];});
P = P.then(async ([database]) => { const val = await database.ref('foo').once('value'); const wb = await val.val(); XLSX.writeFile(wb, "firebase.xlsx"); console.log(csv); return [database];});
P = P.then(async ([database]) => { database.app.delete(); });
</script></body>