Published
Edited
Nov 23, 2020
6 forks
Importers
27 stars
Insert cell
Insert cell
Insert cell
xlsx = require('https://bundle.run/xlsx@0.14.1')
Insert cell
viewof binary = html`<input type=file>`
Insert cell
input = new Uint8Array(await Files.buffer(binary))
Insert cell
wb = xlsx.read(input, {type: 'array'})
Insert cell
viewof sheet_name = select({options: wb.SheetNames, title: 'Sheet name'})
Insert cell
ws = wb.Sheets[sheet_name]
Insert cell
headers = Object.keys(xlsx.utils.sheet_to_json(wb.Sheets[sheet_name])[0])
Insert cell
as_json = xlsx.utils.sheet_to_json(ws)
Insert cell
table(as_json)
Insert cell
out_sheet = xlsx.utils.json_to_sheet(as_json, {header: headers})
Insert cell
write_sheet = out_sheet => {
const wb = xlsx.utils.book_new()
xlsx.utils.book_append_sheet(wb, out_sheet, 'output')
xlsx.writeFile(wb, 'out.xlsx')
}
Insert cell
import {table} from "@tmcw/tables"
Insert cell
import {checkbox, text, select} from '@jashkenas/inputs'
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more