From 89ab3cc4aa314767d082e22f863d17bcd2d0c78f Mon Sep 17 00:00:00 2001 From: SheetJS Date: Thu, 28 Jul 2022 01:36:09 -0400 Subject: [PATCH] requirejs --- .../04-getting-started/03-demos/09-bundler.md | 30 +++++++++++ docz/docs/07-csf/07-features/01-formulae.md | 10 ++-- docz/docs/07-csf/07-features/02-hyperlinks.md | 6 ++- docz/docs/07-csf/07-features/03-dates.md | 4 ++ docz/static/requirejs/requirejs.html | 50 +++++++++++++++++++ 5 files changed, 93 insertions(+), 7 deletions(-) create mode 100644 docz/static/requirejs/requirejs.html diff --git a/docz/docs/04-getting-started/03-demos/09-bundler.md b/docz/docs/04-getting-started/03-demos/09-bundler.md index 3ccaf60..403f251 100644 --- a/docz/docs/04-getting-started/03-demos/09-bundler.md +++ b/docz/docs/04-getting-started/03-demos/09-bundler.md @@ -431,6 +431,36 @@ click the "Click to Export!" button to generate a file. +## RequireJS + +[Standalone scripts](../../installation/standalone) comply with AND `define` +semantics, enabling use in RequireJS out of the box. + +To enable use of the alias `xlsx`, the RequireJS config should set an alias in +the `paths` property: + +```js +require.config({ + baseUrl: ".", + name: "app", + paths: { + // highlight-next-line + xlsx: "xlsx.full.min" + } +}); +// highlight-next-line +require(["xlsx"], function(XLSX) { + /* use XLSX here */ + console.log(XLSX.version); +}); +``` + +The [Live demo](pathname:///requirejs/requirejs.html) loads RequireJS from the +CDN, uses it to load the standalone script from the SheetJS CDN, and uses the +`XLSX` variable to create a button click handler that creates a workbook. + +The `r.js` optimizer also supports the standalone scripts. + ## Snowpack Snowpack works with no caveats. diff --git a/docz/docs/07-csf/07-features/01-formulae.md b/docz/docs/07-csf/07-features/01-formulae.md index bf32c68..0617945 100644 --- a/docz/docs/07-csf/07-features/01-formulae.md +++ b/docz/docs/07-csf/07-features/01-formulae.md @@ -74,14 +74,14 @@ const workbook = XLSX.readFile("test.xlsx", { cellFormula: true }); -Typically file data will be available as a `Buffer` from a network request / API +Typically file data will be available as a `Uint8Array` from a network request or stored in the filesystem. `cellFormula: true` should be added to the second options argument to `read` or `readFile`: **`XLSX.read`** ```js -/* using read in NodeJS, `cellFormula` is in the second argument */ +/* using read in Bun, `cellFormula` is in the second argument */ const ab = await (await fetch("test.xlsx")).arrayBuffer(); const workbook = XLSX.read(ab, { cellFormula: true }); // ------------------------------^^^^^^^^^^^^^^^^^ @@ -90,7 +90,7 @@ const workbook = XLSX.read(ab, { cellFormula: true }); **`XLSX.readFile`** ```js -/* using readFile in NodeJS, add `cellFormula` to the second argument */ +/* using readFile in Bun, add `cellFormula` to the second argument */ const workbook = XLSX.readFile("test.xlsx", { cellFormula: true }); // -------------------------------------------^^^^^^^^^^^^^^^^^ ``` @@ -208,9 +208,7 @@ function ExportSimpleFormula(props) { XLSX.writeFile(wb, "SheetJSFormula1.xlsx"); }); - return (<> - - ); + return (); } ``` diff --git a/docz/docs/07-csf/07-features/02-hyperlinks.md b/docz/docs/07-csf/07-features/02-hyperlinks.md index 45295e7..3205cb3 100644 --- a/docz/docs/07-csf/07-features/02-hyperlinks.md +++ b/docz/docs/07-csf/07-features/02-hyperlinks.md @@ -33,7 +33,7 @@ extends this export with support for hyperlink styling. HTTP / HTTPS links can be used directly: ```js -ws["A2"].l = { Target: "https://docs.sheetjs.com/#hyperlinks" }; +ws["A2"].l = { Target: "https://docs.sheetjs.com/docs/csf/features/hyperlinks" }; ws["A3"].l = { Target: "http://localhost:7262/yes_localhost_works" }; ``` @@ -60,9 +60,13 @@ ws["B3"].l = { Target: "SheetJS.xlsb" }; /* Link to SheetJS.xlsb */ ws["B4"].l = { Target: "../SheetJS.xlsm" }; /* Link to ../SheetJS.xlsm */ ``` +:::caution + Relative Paths have undefined behavior in the SpreadsheetML 2003 format. Excel 2019 will treat a `..\` parent mark as two levels up. +::: + ## Internal Links Links where the target is a cell or range or defined name in the same workbook diff --git a/docz/docs/07-csf/07-features/03-dates.md b/docz/docs/07-csf/07-features/03-dates.md index eadda64..bcb1751 100644 --- a/docz/docs/07-csf/07-features/03-dates.md +++ b/docz/docs/07-csf/07-features/03-dates.md @@ -62,6 +62,8 @@ The following table covers some common formats: | `A/P` | Meridien ("A" or "P") | | `AM/PM` | Meridien ("AM" or "PM") | +:::note + `m` and `mm` are context-dependent. It is interpreted as "minutes" when the previous or next date token represents a time (hours or seconds): @@ -71,6 +73,8 @@ yyyy-mm-dd hh:mm:ss month minutes ``` +::: + ### 1904 and 1900 Date Systems diff --git a/docz/static/requirejs/requirejs.html b/docz/static/requirejs/requirejs.html new file mode 100644 index 0000000..c8503e9 --- /dev/null +++ b/docz/static/requirejs/requirejs.html @@ -0,0 +1,50 @@ + + + + +

SheetJS Presidents Demo

+ + + + +