#!/bin/bash # https://docs.sheetjs.com/docs/demos/data/pouchdb cd /tmp rm -rf sheetjs-pouch mkdir sheetjs-pouch cd sheetjs-pouch # official url is https://github.com/nickcolley/getting-started-todo/archive/master.zip curl -LO https://docs.sheetjs.com/pouchdb/master.zip unzip master.zip cd getting-started-todo-master awk 'NR>1{print p} {p = $0}' js/app.js > export_code.js cat >> export_code.js << 'EOF' document.getElementById("xport").addEventListener("click", function() { console.log("clicked"); db.allDocs({include_docs: true, descending: true}, function(err, doc) { const aoo = doc.rows.map(r => { const { _id, _rev, ...rest } = r.doc; return rest; }); const ws = XLSX.utils.json_to_sheet(aoo); const wb = XLSX.utils.book_new(); XLSX.utils.book_append_sheet(wb, ws, "Sheet1"); XLSX.writeFile(wb, "SheetJSPouch.xlsx"); }); }); })(); EOF cp export_code.js js/app.js sed -i.bak 's|
|