Skip to content

Commit ee8b37b

Browse files
committed
ODS XML Parse nit
1 parent 4a31cb9 commit ee8b37b

File tree

20 files changed

+2993
-78
lines changed

20 files changed

+2993
-78
lines changed

.github/workflows/deno.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ name: 'Tests: deno 1.x'
33
on: [pull_request, push]
44

55
jobs:
6-
# small test
7-
misc:
6+
# full test
7+
full:
8+
name: 'full (with codepage)'
89
runs-on: ubuntu-latest
9-
env:
10-
FMTS: misc
1110
steps:
1211
- uses: actions/checkout@v2
1312
- uses: denoland/setup-deno@main
@@ -21,8 +20,9 @@ jobs:
2120
- run: make init
2221
- run: 'cd test_files; make all; cd -'
2322
- run: deno test --allow-env --allow-read --allow-write --config misc/test.deno.jsonc test.ts
24-
# full test
25-
full:
23+
# full test (no codepage)
24+
fullnocp:
25+
name: 'full (no codepage)'
2626
runs-on: ubuntu-latest
2727
steps:
2828
- uses: actions/checkout@v2
@@ -36,4 +36,4 @@ jobs:
3636
- run: sudo chmod a+x /usr/bin/rooster
3737
- run: make init
3838
- run: 'cd test_files; make all; cd -'
39-
- run: deno test --allow-env --allow-read --allow-write --config misc/test.deno.jsonc test.ts
39+
- run: deno test --allow-env --allow-read --allow-write --config misc/test.deno.jsonc testnocp.ts

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ test.ts: test.mts
148148
test-deno: test.ts ## Run Deno test suite
149149
deno test --allow-env --allow-read --allow-write --config misc/test.deno.jsonc $<
150150

151+
.PHONY: test-denocp
152+
test-denocp: testnocp.ts ## Run Deno test suite (without codepage)
153+
deno test --allow-env --allow-read --allow-write --config misc/test.deno.jsonc $<
154+
151155
#* To run tests for one format, make test_<fmt>
152156
#* To run the core test suite, make test_misc
153157
TESTFMT=$(patsubst %,test_%,$(FMT))

bits/04_base64.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,32 @@ function Base64_encode(input) {
1919
}
2020
return o;
2121
}
22+
function Base64_encode_pass(input) {
23+
var o = "";
24+
var c1 = 0, c2 = 0, c3 = 0, e1 = 0, e2 = 0, e3 = 0, e4 = 0;
25+
for (var i = 0; i < input.length; ) {
26+
c1 = input.charCodeAt(i++);
27+
if (c1 > 255)
28+
c1 = 95;
29+
e1 = c1 >> 2;
30+
c2 = input.charCodeAt(i++);
31+
if (c2 > 255)
32+
c2 = 95;
33+
e2 = (c1 & 3) << 4 | c2 >> 4;
34+
c3 = input.charCodeAt(i++);
35+
if (c3 > 255)
36+
c3 = 95;
37+
e3 = (c2 & 15) << 2 | c3 >> 6;
38+
e4 = c3 & 63;
39+
if (isNaN(c2)) {
40+
e3 = e4 = 64;
41+
} else if (isNaN(c3)) {
42+
e4 = 64;
43+
}
44+
o += Base64_map.charAt(e1) + Base64_map.charAt(e2) + Base64_map.charAt(e3) + Base64_map.charAt(e4);
45+
}
46+
return o;
47+
}
2248
function Base64_decode(input) {
2349
var o = "";
2450
var c1 = 0, c2 = 0, c3 = 0, e1 = 0, e2 = 0, e3 = 0, e4 = 0;

bits/20_jsutils.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,7 @@ function fuzzydate(s/*:string*/)/*:Date*/ {
184184
lower = lower.replace(/[^a-z]/g,"").replace(/([^a-z]|^)[ap]m?([^a-z]|$)/,"");
185185
if(lower.length > 3 && lower_months.indexOf(lower) == -1) return n;
186186
} else if(lower.replace(/[ap]m?/, "").match(/[a-z]/)) return n;
187-
if(y < 0 || y > 8099) return n;
188-
if((m > 0 || d > 1) && y != 101) return o;
189-
if(s.match(/[^-0-9:,\/\\]/)) return n;
187+
if(y < 0 || y > 8099 || s.match(/[^-0-9:,\/\\]/)) return n;
190188
return o;
191189
}
192190

bits/22_xmlutils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ function xlml_normalize(d)/*:string*/ {
246246
throw new Error("Bad input format: expected Buffer or string");
247247
}
248248
/* UOS uses CJK in tags */
249-
var xlmlregex = /<(\/?)([^\s?><!\/:]*:|)([^\s?<>:\/]+)(?:[\s?:\/][^>]*)?>/mg;
249+
var xlmlregex = /<(\/?)([^\s?><!\/:]*:|)([^\s?<>:\/]+)(?:[\s?:\/](?:[^>=]|="[^"]*?")*)?>/mg;
250250
//var xlmlregex = /<(\/?)([a-z0-9]*:|)(\w+)[^>]*>/mg;
251251

252252
var XMLNS = ({

bits/88_write.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function write_string_type(out/*:string*/, opts/*:WriteOpts*/, bom/*:?string*/)/
8181

8282
function write_stxt_type(out/*:string*/, opts/*:WriteOpts*/)/*:any*/ {
8383
switch(opts.type) {
84-
case "base64": return Base64_encode(out);
84+
case "base64": return Base64_encode_pass(out);
8585
case "binary": return out;
8686
case "string": return out; /* override in sheet_to_txt */
8787
case "file": return write_dl(opts.file, out, 'binary');

demos/README.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,32 +29,36 @@ can be installed with Bash on Windows or with `cygwin`.
2929
- [`databases and key/value stores`](database/)
3030
- [`typed arrays and math`](array/)
3131

32-
**Bundlers and Tooling**
33-
- [`browserify`](browserify/)
34-
- [`parcel`](parcel/)
35-
- [`requirejs`](requirejs/)
36-
- [`rollup`](rollup/)
37-
- [`systemjs`](systemjs/)
38-
- [`typescript`](typescript/)
39-
- [`webpack 2.x`](webpack/)
32+
**Front-End UI Components**
33+
- [`canvas-datagrid`](datagrid/)
34+
- [`x-spreadsheet`](xspreadsheet/)
35+
- [`react-data-grid`](react/modify/)
36+
- [`vue3-table-light`](/vue/modify/)
4037

4138
**Platforms and Integrations**
4239
- [`deno`](deno/)
4340
- [`electron application`](electron/)
4441
- [`nw.js application`](nwjs/)
4542
- [`Chrome / Chromium extensions`](chrome/)
4643
- [`Google Sheets API`](https://docs.sheetjs.com/docs/getting-started/demos/gsheet)
47-
- [`Adobe Apps`](https://docs.sheetjs.com/docs/getting-started/demos/extendscript)
44+
- [`ExtendScript for Adobe Apps`](https://docs.sheetjs.com/docs/getting-started/demos/extendscript)
45+
- [`NetSuite SuiteScript`](https://docs.sheetjs.com/docs/getting-started/demos/netsuite)
46+
- [`SalesForce Lightning Web Components`](https://docs.sheetjs.com/docs/getting-started/demos/salesforce)
4847
- [`Excel JavaScript API`](https://docs.sheetjs.com/docs/getting-started/demos/excel)
4948
- [`Headless Browsers`](headless/)
50-
- [`canvas-datagrid`](datagrid/)
51-
- [`x-spreadsheet`](xspreadsheet/)
52-
- [`react-data-grid`](react/modify/)
53-
- [`vue3-table-light`](/vue/modify/)
5449
- [`Swift JSC and other engines`](altjs/)
5550
- [`"serverless" functions`](function/)
5651
- [`internet explorer`](oldie/)
5752

53+
**Bundlers and Tooling**
54+
- [`browserify`](browserify/)
55+
- [`parcel`](parcel/)
56+
- [`requirejs`](requirejs/)
57+
- [`rollup`](rollup/)
58+
- [`systemjs`](systemjs/)
59+
- [`typescript`](typescript/)
60+
- [`webpack 2.x`](webpack/)
61+
5862
Other examples are included in the [showcase](demos/showcase/).
5963

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

demos/database/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ The `sheet_to_json` helper function generates arrays of JS objects that can be
4848
scanned to determine the column "types", and there are third-party connectors
4949
that can push arrays of JS objects to database tables.
5050

51-
The [`sexql`](http://sheetjs.com/sexql) browser demo uses WebSQL, which is
51+
The [`sql`](http://sheetjs.com/sql) browser demo uses WebSQL, which is
5252
limited to the SQLite fundamental types.
5353

5454
<details>
5555
<summary><b>Implementation details</b> (click to show)</summary>
5656

57-
The `sexql` schema builder scans the first row to find headers:
57+
The `sql` schema builder scans the first row to find headers:
5858

5959
```js
6060
if(!ws || !ws['!ref']) return;
@@ -202,11 +202,11 @@ function object_to_workbook(obj) {
202202

203203
#### WebSQL
204204

205-
WebSQL is a popular SQL-based in-browser database available on Chrome / Safari.
206-
In practice, it is powered by SQLite, and most simple SQLite-compatible queries
205+
WebSQL is a popular SQL-based in-browser database available on Chrome. In
206+
practice, it is powered by SQLite, and most simple SQLite-compatible queries
207207
work as-is in WebSQL.
208208

209-
The public demo <http://sheetjs.com/sexql> generates a database from workbook.
209+
The public demo <http://sheetjs.com/sql> generates a database from workbook.
210210

211211
#### LocalStorage and SessionStorage
212212

@@ -259,9 +259,9 @@ the `sheetj5` database and verifies the tables are preserved.
259259

260260
#### PostgreSQL
261261

262-
[The `pg` module](https://www.npmjs.com/package/pg) supplies a Promise wrapper.
263-
Like with `mysql2`, `Client#query` runs a statement and returns a result object.
264-
The `rows` key of the object is an array of JS objects.
262+
[The `pg` module](https://node-postgres.com/) supplies a Promise wrapper.
263+
`Client#query` runs a statement and returns a result object. The `rows` key of
264+
the object is an array of JS objects.
265265

266266
`PgSQLTest.js` connects to the PostgreSQL server on `localhost`, builds two
267267
tables in the `sheetjs` database, exports to XLSX, imports the new XLSX file to

demos/electron/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
out/

demos/electron/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ lint:
1010
run:
1111
npm i
1212
npx electron .
13+
.PHONY: build
14+
build:
15+
npm run make

0 commit comments

Comments
 (0)