8000 package.json exports · SheetJS/sheetjs@c03bc18 · GitHub
[go: up one dir, main page]

Skip to content

Commit c03bc18

Browse files
committed
package.json exports
1 parent 9a36af0 commit c03bc18

File tree

13 files changed

+38
-482
lines changed

13 files changed

+38
-482
lines changed

bits/90_utils.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,10 @@ function sheet_to_formulae(sheet/*:Worksheet*/)/*:Array<string>*/ {
191191

192192
function sheet_add_json(_ws/*:?Worksheet*/, js/*:Array<any>*/, opts)/*:Worksheet*/ {
193193
var o = opts || {};
194+
var dense = _ws ? Array.isArray(_ws) : o.dense;
195+
if(DENSE != null && dense == null) dense = DENSE;
194196
var offset = +!o.skipHeader;
195-
var ws/*:Worksheet*/ = _ws || ({}/*:any*/);
197+
var ws/*:Worksheet*/ = _ws || (dense ? ([]/*:any*/) : ({}/*:any*/));
196198
var _R = 0, _C = 0;
197199
if(ws && o.origin != null) {
198200
if(typeof o.origin == 'number') _R = o.origin;
@@ -233,7 +235,13 @@ function sheet_add_json(_ws/*:?Worksheet*/, js/*:Array<any>*/, opts)/*:Worksheet
233235
z = (cell.z && fmt_is_date(cell.z)) ? cell.z : (o.dateNF || table_fmt[14]); 8000
234236
}
235237
else if(v === null && o.nullError) { t = 'e'; v = 0; }
236-
if(!cell) ws[ref] = cell = ({t:t, v:v}/*:any*/);
238+
if(!cell) {
239+
if(!dense) ws[ref] = cell = ({t:t, v:v}/*:any*/);
240+
else {
241+
if(!ws[_R + R + offset]) ws[_R + R + offset] = [];
242+
ws[_R + R + offset][_C + C] = cell = ({t:t, v:v}/*:any*/);
243+
}
244+
}
237245
else {
238246
cell.t = t; cell.v = v;
239247
delete cell.w; delete cell.R;
@@ -245,7 +253,11 @@ function sheet_add_json(_ws/*:?Worksheet*/, js/*:Array<any>*/, opts)/*:Worksheet
245253
});
246254
range.e.c = Math.max(range.e.c, _C + hdr.length - 1);
247255
var __R = encode_row(_R);
248-
if(offset) for(C = 0; C < hdr.length; ++C) ws[encode_col(C + _C) + __R] = {t:'s', v:hdr[C]};
256+
if(dense && !ws[_R]) ws[_R] = [];
257+
if(offset) for(C = 0; C < hdr.length; ++C) {
258+
if(dense) ws[_R][C + _C] = {t:'s', v:hdr[C]};
259+
else ws[encode_col(C + _C) + __R] = {t:'s', v:hdr[C]};
260+
}
249261
ws['!ref'] = encode_range(range);
250262
return ws;
251263
}

demos/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@ can be installed with Bash on Windows or with `cygwin`.
5454
- [`internet explorer`](oldie/)
5555

5656
**Bundlers and Tooling**
57-
- [`browserify`](browserify/)
58-
- [`parcel`](parcel/)
57+
- [`browserify`](https://docs.sheetjs.com/docs/getting-started/demos/bundler#browserify)
58+
- [`bun`](https://docs.sheetjs.com/docs/getting-started/demos/bundler#bun)
59+
- [`esbuild`](https://docs.sheetjs.com/docs/getting-started/demos/bundler#esbuild)
60+
- [`parcel`](https://docs.sheetjs.com/docs/getting-started/demos/bundler#parcel)
5961
- [`requirejs`](requirejs/)
6062
- [`rollup`](rollup/)
6163
- [`systemjs`](systemjs/)

demos/browserify/Makefile

Lines changed: 0 additions & 17 deletions
This file was deleted.

demos/browserify/README.md

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,6 @@
11
# Browserify
22

3-
The library is compatible with Browserify and should just work out of the box.
4-
5-
This demo uses the `require` form to expose the whole library, enabling client
6-
code to access the library with `var XLSX = require('xlsx')`. The JS code from
7-
the root demo was moved to a separate `app.js` script. That script is bundled:
8-
9-
```bash
10-
browserify app.js > browserify.js
11-
uglifyjs browserify.js > browserify.min.js
12-
```
13-
14-
### Worker Scripts
15-
16-
Browserify can also bundle worker scripts! Instead of using `importScripts`,
17-
the worker script should require the module:
18-
19-
```diff
20-
-importScripts('dist/xlsx.full.min.js');
21-
+var XLSX = require('xlsx');
22-
```
23-
24-
The same process generates the worker script:
25-
26-
```bash
27-
browserify xlsxworker.js > worker.js
28-
uglifyjs worker.js > worker.min.js
29-
```
3+
[The new demo](https://docs.sheetjs.com/docs/getting-started/demos/bundler#browserify)
4+
includes a more concise example.
305

316
[![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-xlsx?pixel)](https://github.com/SheetJS/js-xlsx)

demos/browserify/app.js

Lines changed: 0 additions & 149 deletions
This file was deleted.

demos/browserify/browserify.html

Lines changed: 0 additions & 62 deletions
This file was deleted.

demos/browserify/xlsxworker.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

demos/parcel/Makefile

Lines changed: 0 additions & 12 deletions
This file was deleted.

demos/parcel/README.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
# Parcel
22

3-
Parcel Bundler starting from version 1.5.0 should play nice with this library
4-
out of the box:
5-
6-
```js
7-
import { read, write, utils } from 'xlsx'
8-
```
9-
10-
Errors of the form `Could not statically evaluate fs call` stem from a parcel
11-
[bug](https://github.com/parcel-bundler/parcel/pull/523#issuecomment-357486164).
12-
Upgrade to version 1.5.0 or later.
3+
[The new demo](https://docs.sheetjs.com/docs/getting-started/demos/bundler#parcel)
4+
includes a more concise example.
135

146
[![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-xlsx?pixel)](https://github.com/SheetJS/js-xlsx)

0 commit comments

Comments
 (0)
0