From c4276865cd36e577b6e8e236c6c7857a11773267 Mon Sep 17 00:00:00 2001 From: SheetJS Date: Sat, 9 Jul 2022 19:59:44 -0400 Subject: [PATCH] bun --- docz/docs/02-installation/07-bun.md | 42 +++++++++++++++++++++++++++++ docz/docs/06-solutions/01-input.md | 13 +++++++++ 2 files changed, 55 insertions(+) create mode 100644 docz/docs/02-installation/07-bun.md diff --git a/docz/docs/02-installation/07-bun.md b/docz/docs/02-installation/07-bun.md new file mode 100644 index 0000000..aff4730 --- /dev/null +++ b/docz/docs/02-installation/07-bun.md @@ -0,0 +1,42 @@ +--- +sidebar_position: 7 +sidebar_custom_props: + summary: Download and Import ECMAScript Modules +--- + +import current from '/version.js'; + +# Bun + +[Bun](https://bun.sh/) is a JavaScript runtime powered by JavaScriptCore. + +:::caution Bun support is considered experimental. + +Great open source software grows with user tests and reports. Any issues should +be reported to the [SheetJS project](https://github.com/SheetJS/sheetjs/issues) +for further diagnosis. + +::: + +Each standalone release script is available at . + +
https://cdn.sheetjs.com/xlsx-{current}/package/xlsx.mjs is the URL for {current}

+ +After downloading the script, it can be directly imported: + +```js +import * as XLSX from './xlsx.mjs'; +``` + +## XLS Support + +If XLS support is required, `cpexcel.full.mjs` must be manually imported. + +
https://cdn.sheetjs.com/xlsx-{current}/package/dist/cpexcel.full.mjs is the URL for {current}

+ + +```ts +/* load the codepage support library for extended support with older formats */ +import * as cptable from './cpexcel.full.mjs'; +XLSX.set_cptable(cptable); +``` diff --git a/docz/docs/06-solutions/01-input.md b/docz/docs/06-solutions/01-input.md index ed5fb8a..ecd7492 100644 --- a/docz/docs/06-solutions/01-input.md +++ b/docz/docs/06-solutions/01-input.md @@ -177,6 +177,19 @@ var workbook = XLSX.readFile(thisFile.absoluteURI); The [`extendscript` demo](../getting-started/demos/extendscript) includes a more complex example. + + + +[Bun `readFileSync`](https://github.com/Jarred-Sumner/bun/issues/256) currently +returns a `Uint8Array`. The result should be wrapped in a `Buffer`: + +```js +import { readFileSync } from 'fs' +import { read } from './xlsx.mjs' + +const workbook = read(Buffer.from(readFileSync(path))); +``` +