forked from sheetjs/sheetjs
version bump 0.11.11: CFB miscellany
- export `sheet_to_txt` (fixes #905 h/t @aj4mq) - BIFF4 Format Record aligned to BIFF 2/3 (fixes #909 h/t @ToujouAya) - updated CFB to 1.0.1 - typescript standalone demo - nexe / pkg xlsx.njs demo
This commit is contained in:
parent
a0bc73da69
commit
cd2e639fc2
@ -65,6 +65,7 @@ config
|
||||
customizable
|
||||
datagrid
|
||||
deduplication
|
||||
destructuring
|
||||
embeddable
|
||||
filesystem
|
||||
javascript
|
||||
|
9
Makefile
9
Makefile
@ -89,7 +89,14 @@ legend.png: misc/legend.dot
|
||||
nexe: xlsx.exe ## Build nexe standalone executable
|
||||
|
||||
xlsx.exe: bin/xlsx.njs xlsx.js
|
||||
nexe -i $< -o $@ --flags
|
||||
tail -n+2 $< | sed 's#\.\./#./xlsx#g' > nexe.js
|
||||
nexe -i nexe.js -o $@
|
||||
head nexe.js
|
||||
rm nexe.js
|
||||
|
||||
.PHONY: pkg
|
||||
pkg: bin/xlsx.njs xlsx.js ## Build pkg standalone executable
|
||||
pkg $<
|
||||
|
||||
## Testing
|
||||
|
||||
|
@ -200,6 +200,7 @@ The [`demos` directory](demos/) includes sample projects for:
|
||||
- [`requirejs`](demos/requirejs/)
|
||||
- [`rollup`](demos/rollup/)
|
||||
- [`systemjs`](demos/systemjs/)
|
||||
- [`typescript`](demos/typescript/)
|
||||
- [`webpack 2.x`](demos/webpack/)
|
||||
|
||||
**Platforms and Integrations**
|
||||
@ -569,6 +570,7 @@ files and output the contents in various formats. The source is available at
|
||||
Some helper functions in `XLSX.utils` generate different views of the sheets:
|
||||
|
||||
- `XLSX.utils.sheet_to_csv` generates CSV
|
||||
- `XLSX.utils.sheet_to_txt` generates UTF16 Formatted Text
|
||||
- `XLSX.utils.sheet_to_html` generates HTML
|
||||
- `XLSX.utils.sheet_to_json` generates an array of objects
|
||||
- `XLSX.utils.sheet_to_formulae` generates a list of formulae
|
||||
@ -730,6 +732,7 @@ Utilities are available in the `XLSX.utils` object and are described in the
|
||||
|
||||
- `sheet_to_json` converts a worksheet object to an array of JSON objects.
|
||||
- `sheet_to_csv` generates delimiter-separated-values output.
|
||||
- `sheet_to_txt` generates UTF16 formatted text.
|
||||
- `sheet_to_html` generates HTML output.
|
||||
- `sheet_to_formulae` generates a list of the formulae (with value fallbacks).
|
||||
|
||||
@ -1850,6 +1853,8 @@ The `txt` output type uses the tab character as the field separator. If the
|
||||
`codepage` library is available (included in full distribution but not core),
|
||||
the output will be encoded in `CP1200` and the BOM will be prepended.
|
||||
|
||||
`XLSX.utils.sheet_to_txt` takes the same arguments as `sheet_to_csv`.
|
||||
|
||||
### HTML Output
|
||||
|
||||
As an alternative to the `writeFile` HTML type, `XLSX.utils.sheet_to_html` also
|
||||
|
@ -1 +1 @@
|
||||
XLSX.version = '0.11.10';
|
||||
XLSX.version = '0.11.11';
|
||||
|
@ -14,4 +14,4 @@ function s2a(s/*:string*/) {
|
||||
|
||||
var bconcat = function(bufs) { return [].concat.apply([], bufs); };
|
||||
|
||||
var chr0 = /\u0000/g, chr1 = /[\u0001-\u0006]/;
|
||||
var chr0 = /\u0000/g, chr1 = /[\u0001-\u0006]/g;
|
||||
|
@ -38,7 +38,7 @@ type CFBFiles = {[n:string]:CFBEntry};
|
||||
/* [MS-CFB] v20130118 */
|
||||
var CFB = (function _CFB(){
|
||||
var exports/*:CFBModule*/ = /*::(*/{}/*:: :any)*/;
|
||||
exports.version = '1.0.0';
|
||||
exports.version = '1.0.1';
|
||||
/* [MS-CFB] 2.6.4 */
|
||||
function namecmp(l/*:string*/, r/*:string*/)/*:number*/ {
|
||||
var L = l.split("/"), R = r.split("/");
|
||||
|
@ -41,6 +41,7 @@ function parse_DataSpaceMapEntry(blob) {
|
||||
}
|
||||
o.name = blob.read_shift(0, 'lpp4');
|
||||
o.comps = comps;
|
||||
if(blob.l != end) throw new Error("Bad DataSpaceMapEntry: " + blob.l + " != " + end);
|
||||
return o;
|
||||
}
|
||||
|
||||
@ -69,7 +70,7 @@ function parse_TransformInfoHeader(blob, length) {
|
||||
var tgt = blob.l + len - 4;
|
||||
blob.l += 4; // must be 0x1
|
||||
o.id = blob.read_shift(0, 'lpp4');
|
||||
// tgt == len
|
||||
if(tgt != blob.l) throw new Error("Bad TransformInfoHeader record: " + blob.l + " != " + tgt);
|
||||
o.name = blob.read_shift(0, 'lpp4');
|
||||
o.R = parse_CRYPTOVersion(blob, 4);
|
||||
o.U = parse_CRYPTOVersion(blob, 4);
|
||||
@ -148,13 +149,29 @@ function parse_EncInfoStd(blob, vers) {
|
||||
function parse_EncInfoExt(blob, vers) { throw new Error("File is password-protected: ECMA-376 Extensible"); }
|
||||
/* [MS-OFFCRYPTO] 2.3.4.10 EncryptionInfo Stream (Agile Encryption) */
|
||||
function parse_EncInfoAgl(blob, vers) {
|
||||
var KeyData = ["saltSize","blockSize","keyBits","hashSize","cipherAlgorithm","cipherChaining","hashAlgorithm","saltValue"];
|
||||
blob.l+=4;
|
||||
return blob.read_shift(blob.length - blob.l, 'utf8');
|
||||
var xml = blob.read_shift(blob.length - blob.l, 'utf8');
|
||||
var o = {};
|
||||
xml.replace(tagregex, function xml_agile(x, idx) {
|
||||
var y/*:any*/ = parsexmltag(x);
|
||||
switch(strip_ns(y[0])) {
|
||||
case '<?xml': break;
|
||||
case '<encryption': case '</encryption>': break;
|
||||
case '<keyData': KeyData.forEach(function(k) { o[k] = y[k]; }); break;
|
||||
case '<dataIntegrity': o.encryptedHmacKey = y.encryptedHmacKey; o.encryptedHmacValue = y.encryptedHmacValue; break;
|
||||
case '<keyEncryptors>': case '<keyEncryptors': o.encs = []; break;
|
||||
case '</keyEncryptors>': break;
|
||||
|
||||
case '<keyEncryptor': o.uri = y.uri; break;
|
||||
case '</keyEncryptor>': break;
|
||||
case '<encryptedKey': o.encs.push(y); break;
|
||||
default: throw y[0];
|
||||
}
|
||||
});
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* [MS-OFFCRYPTO] 2.3.5.1 RC4 CryptoAPI Encryption Header */
|
||||
function parse_RC4CryptoHeader(blob, length/*:number*/) {
|
||||
var o = {};
|
||||
|
@ -486,7 +486,12 @@ function parse_workbook(blob, options/*:ParseOpts*/)/*:Workbook*/ {
|
||||
sst = val;
|
||||
} break;
|
||||
case 'Format': { /* val = [id, fmt] */
|
||||
SSF.load(val[1], val[0]);
|
||||
if(opts.biff == 4) {
|
||||
BIFF2FmtTable[BIFF2Fmt++] = val[1];
|
||||
for(var b4idx = 0; b4idx < BIFF2Fmt + 163; ++b4idx) if(SSF._table[b4idx] == val[1]) break;
|
||||
if(b4idx >= 163) SSF.load(val[1], BIFF2Fmt + 163);
|
||||
}
|
||||
else SSF.load(val[1], val[0]);
|
||||
} break;
|
||||
case 'BIFF2FORMAT': {
|
||||
BIFF2FmtTable[BIFF2Fmt++] = val;
|
||||
|
@ -176,40 +176,42 @@ function parse_zip(zip/*:ZIP*/, opts/*:?ParseOpts*/)/*:Workbook*/ {
|
||||
return out;
|
||||
}
|
||||
|
||||
/* references to [MS-OFFCRYPTO] */
|
||||
function parse_xlsxcfb(cfb, opts/*:?ParseOpts*/)/*:Workbook*/ {
|
||||
var f = 'Version';
|
||||
var data = CFB.find(cfb, f);
|
||||
if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
/* [MS-OFFCRYPTO] 2.1.1 */
|
||||
function parse_xlsxcfb(cfb, _opts/*:?ParseOpts*/)/*:Workbook*/ {
|
||||
var opts = _opts || {};
|
||||
var f = '/!DataSpaces/Version';
|
||||
var data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
var version = parse_DataSpaceVersionInfo(data.content);
|
||||
|
||||
/* 2.3.4.1 */
|
||||
f = 'DataSpaceMap';
|
||||
data = CFB.find(cfb, f);
|
||||
if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
f = '/!DataSpaces/DataSpaceMap';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
var dsm = parse_DataSpaceMap(data.content);
|
||||
if(dsm.length !== 1 || dsm[0].comps.length !== 1 || dsm[0].comps[0].t !== 0 || dsm[0].name !== "StrongEncryptionDataSpace" || dsm[0].comps[0].v !== "EncryptedPackage")
|
||||
throw new Error("ECMA-376 Encrypted file bad " + f);
|
||||
|
||||
f = 'StrongEncryptionDataSpace';
|
||||
data = CFB.find(cfb, f);
|
||||
if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
/* 2.3.4.2 */
|
||||
f = '/!DataSpaces/DataSpaceInfo/StrongEncryptionDataSpace';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
var seds = parse_DataSpaceDefinition(data.content);
|
||||
if(seds.length != 1 || seds[0] != "StrongEncryptionTransform")
|
||||
throw new Error("ECMA-376 Encrypted file bad " + f);
|
||||
|
||||
/* 2.3.4.3 */
|
||||
f = '!Primary';
|
||||
data = CFB.find(cfb, f);
|
||||
if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
f = '/!DataSpaces/TransformInfo/StrongEncryptionTransform/!Primary';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
var hdr = parse_Primary(data.content);
|
||||
|
||||
f = 'EncryptionInfo';
|
||||
data = CFB.find(cfb, f);
|
||||
if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
f = '/EncryptionInfo';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
var einfo = parse_EncryptionInfo(data.content);
|
||||
|
||||
if(einfo[0] == 0x04) throw new Error("File is password-protected: ECMA-376 Agile");
|
||||
/* 2.3.4.4 */
|
||||
f = '/EncryptedPackage';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
|
||||
/*:: declare var decrypt_agile:any; */
|
||||
if(einfo[0] == 0x04 && typeof decrypt_agile !== 'undefined') return decrypt_agile(einfo[1], data.content, opts.password || "", opts);
|
||||
throw new Error("File is password-protected");
|
||||
}
|
||||
|
||||
|
@ -219,6 +219,7 @@ var utils/*:any*/ = {
|
||||
table_to_sheet: parse_dom_table,
|
||||
table_to_book: table_to_book,
|
||||
sheet_to_csv: sheet_to_csv,
|
||||
sheet_to_txt: sheet_to_txt,
|
||||
sheet_to_json: sheet_to_json,
|
||||
sheet_to_html: HTML_.from_sheet,
|
||||
sheet_to_formulae: sheet_to_formulae,
|
||||
|
@ -31,6 +31,7 @@ can be installed with Bash on Windows or with `cygwin`.
|
||||
- [`requirejs`](requirejs/)
|
||||
- [`rollup`](rollup/)
|
||||
- [`systemjs`](systemjs/)
|
||||
- [`typescript`](typescript/)
|
||||
- [`webpack 2.x`](webpack/)
|
||||
|
||||
**Platforms and Integrations**
|
||||
|
1
demos/typescript/.gitignore
vendored
Normal file
1
demos/typescript/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
dist
|
3
demos/typescript/Makefile
Normal file
3
demos/typescript/Makefile
Normal file
@ -0,0 +1,3 @@
|
||||
.PHONY: all
|
||||
all:
|
||||
npm run build
|
71
demos/typescript/README.md
Normal file
71
demos/typescript/README.md
Normal file
@ -0,0 +1,71 @@
|
||||
# TypeScript
|
||||
|
||||
The library exports can be imported directly from TS code with:
|
||||
|
||||
```typescript
|
||||
import * as XLSX from 'xlsx';
|
||||
```
|
||||
|
||||
The library type definitions are available in the repo at `types/index.d.ts` and
|
||||
in the node module. The definitions are also available in places that serve the
|
||||
node module, like [unpkg](https://unpkg.com/xlsx/types/index.d.ts).
|
||||
|
||||
This demo shows a small utility function that reads the first worksheet and
|
||||
converts to an array of arrays. The utility function is designed to be used in
|
||||
the browser and server. This project shows a complete deployment as a simple
|
||||
browser script and as a node module.
|
||||
|
||||
This demo is intended to illustrate simple and direct use of the `tsc` command
|
||||
line utility. The Angular 2+ demo shows a more advanced TypeScript deployment.
|
||||
|
||||
|
||||
## Named Exports
|
||||
|
||||
Newer TypeScript versions (2.6+) support named exports:
|
||||
|
||||
```typescript
|
||||
import { read, write, utils } from 'xlsx'
|
||||
```
|
||||
|
||||
However, since this is not supported in all deployments, it is generally easier
|
||||
to use the glob import form and destructuring assignment:
|
||||
|
||||
```typescript
|
||||
import * as XLSX from 'xlsx';
|
||||
const { read, write, utils } = XLSX;
|
||||
```
|
||||
|
||||
|
||||
## Library Type Definitions
|
||||
|
||||
Types are exposed in the node module directly in the path `/types/index.d.ts`.
|
||||
[unpkg CDN includes the definitions](https://unpkg.com/xlsx/types/index.d.ts).
|
||||
The named `@types/xlsx` module should not be installed!
|
||||
|
||||
Using the glob import, types must be explicitly scoped:
|
||||
|
||||
```typescript
|
||||
import * as XLSX from 'xlsx';
|
||||
/* the workbook type is accessible as XLSX.WorkBook */
|
||||
const wb: XLSX.WorkBook = XLSX.read(data, options);
|
||||
```
|
||||
|
||||
Using named imports, the explicit type name should be imported:
|
||||
|
||||
```typescript
|
||||
import { read, WorkBook } from 'xlsx'
|
||||
const wb: WorkBook = read(data, options);
|
||||
```
|
||||
|
||||
|
||||
## Demo Project Structure
|
||||
|
||||
`lib/index.ts` is the TS library that will be transpiled to `dist/index.js` and
|
||||
`dist/index.d.ts`.
|
||||
|
||||
`demo.js` is a node script that uses the generated library.
|
||||
|
||||
`src/index.js` is the browser entry point. The `browserify` bundle tool is used
|
||||
to generate `dist/browser.js`, a browser script loaded by `index.html`.
|
||||
|
||||
[![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/js-xlsx?pixel)](https://github.com/SheetJS/js-xlsx)
|
2
demos/typescript/demo.js
Normal file
2
demos/typescript/demo.js
Normal file
@ -0,0 +1,2 @@
|
||||
var readFirstSheet = require("./").readFirstSheet;
|
||||
console.log(readFirstSheet("../../sheetjs.xlsb", {type:"file", cellDates:true}));
|
1
demos/typescript/index.html
Normal file
1
demos/typescript/index.html
Normal file
@ -0,0 +1 @@
|
||||
<script src="dist/browser.js"></script>
|
12
demos/typescript/lib/index.ts
Normal file
12
demos/typescript/lib/index.ts
Normal file
@ -0,0 +1,12 @@
|
||||
/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
|
||||
/* vim: set ts=2: */
|
||||
|
||||
import * as XLSX from 'xlsx';
|
||||
|
||||
const { read, utils: { sheet_to_json } } = XLSX;
|
||||
|
||||
export function readFirstSheet(data:any, options:XLSX.ParsingOptions): any[][] {
|
||||
const wb: XLSX.WorkBook = read(data, options);
|
||||
const ws: XLSX.WorkSheet = wb.Sheets[wb.SheetNames[0]];
|
||||
return sheet_to_json(ws, {header:1, raw:true});
|
||||
};
|
19
demos/typescript/package.json
Normal file
19
demos/typescript/package.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "xlsx-ts",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"version": "0.0.0",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"build": "tsc && browserify -o dist/browser.js src/index.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"xlsx": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "~2.6.1",
|
||||
"browserify": "~14.5.0"
|
||||
}
|
||||
}
|
2
demos/typescript/src/index.js
Normal file
2
demos/typescript/src/index.js
Normal file
@ -0,0 +1,2 @@
|
||||
var readFirstSheet = require("../").readFirstSheet;
|
||||
console.log(readFirstSheet("a,b,c\n1,2,3\n4,5,6", {type:"binary"}));
|
9
demos/typescript/tsconfig.json
Normal file
9
demos/typescript/tsconfig.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"declaration": true,
|
||||
"outDir": "./dist",
|
||||
"strict": true
|
||||
}
|
||||
}
|
26
dist/xlsx.core.min.js
vendored
26
dist/xlsx.core.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/xlsx.core.min.map
vendored
2
dist/xlsx.core.min.map
vendored
File diff suppressed because one or more lines are too long
22
dist/xlsx.full.min.js
vendored
22
dist/xlsx.full.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/xlsx.full.min.map
vendored
2
dist/xlsx.full.min.map
vendored
File diff suppressed because one or more lines are too long
78
dist/xlsx.js
vendored
78
dist/xlsx.js
vendored
@ -4,7 +4,7 @@
|
||||
/*global global, exports, module, require:false, process:false, Buffer:false */
|
||||
var XLSX = {};
|
||||
(function make_xlsx(XLSX){
|
||||
XLSX.version = '0.11.10';
|
||||
XLSX.version = '0.11.11';
|
||||
var current_codepage = 1200;
|
||||
/*global cptable:true */
|
||||
if(typeof module !== "undefined" && typeof require !== 'undefined') {
|
||||
@ -105,7 +105,7 @@ function s2a(s) {
|
||||
|
||||
var bconcat = function(bufs) { return [].concat.apply([], bufs); };
|
||||
|
||||
var chr0 = /\u0000/g, chr1 = /[\u0001-\u0006]/;
|
||||
var chr0 = /\u0000/g, chr1 = /[\u0001-\u0006]/g;
|
||||
/* ssf.js (C) 2013-present SheetJS -- http://sheetjs.com */
|
||||
/*jshint -W041 */
|
||||
var SSF = ({});
|
||||
@ -1026,7 +1026,7 @@ var DO_NOT_EXPORT_CFB = true;
|
||||
/* [MS-CFB] v20130118 */
|
||||
var CFB = (function _CFB(){
|
||||
var exports = {};
|
||||
exports.version = '1.0.0';
|
||||
exports.version = '1.0.1';
|
||||
/* [MS-CFB] 2.6.4 */
|
||||
function namecmp(l, r) {
|
||||
var L = l.split("/"), R = r.split("/");
|
||||
@ -6844,6 +6844,7 @@ function parse_DataSpaceMapEntry(blob) {
|
||||
}
|
||||
o.name = blob.read_shift(0, 'lpp4');
|
||||
o.comps = comps;
|
||||
if(blob.l != end) throw new Error("Bad DataSpaceMapEntry: " + blob.l + " != " + end);
|
||||
return o;
|
||||
}
|
||||
|
||||
@ -6872,7 +6873,7 @@ function parse_TransformInfoHeader(blob, length) {
|
||||
var tgt = blob.l + len - 4;
|
||||
blob.l += 4; // must be 0x1
|
||||
o.id = blob.read_shift(0, 'lpp4');
|
||||
// tgt == len
|
||||
if(tgt != blob.l) throw new Error("Bad TransformInfoHeader record: " + blob.l + " != " + tgt);
|
||||
o.name = blob.read_shift(0, 'lpp4');
|
||||
o.R = parse_CRYPTOVersion(blob, 4);
|
||||
o.U = parse_CRYPTOVersion(blob, 4);
|
||||
@ -6951,13 +6952,29 @@ function parse_EncInfoStd(blob, vers) {
|
||||
function parse_EncInfoExt(blob, vers) { throw new Error("File is password-protected: ECMA-376 Extensible"); }
|
||||
/* [MS-OFFCRYPTO] 2.3.4.10 EncryptionInfo Stream (Agile Encryption) */
|
||||
function parse_EncInfoAgl(blob, vers) {
|
||||
var KeyData = ["saltSize","blockSize","keyBits","hashSize","cipherAlgorithm","cipherChaining","hashAlgorithm","saltValue"];
|
||||
blob.l+=4;
|
||||
return blob.read_shift(blob.length - blob.l, 'utf8');
|
||||
var xml = blob.read_shift(blob.length - blob.l, 'utf8');
|
||||
var o = {};
|
||||
xml.replace(tagregex, function xml_agile(x, idx) {
|
||||
var y = parsexmltag(x);
|
||||
switch(strip_ns(y[0])) {
|
||||
case '<?xml': break;
|
||||
case '<encryption': case '</encryption>': break;
|
||||
case '<keyData': KeyData.forEach(function(k) { o[k] = y[k]; }); break;
|
||||
case '<dataIntegrity': o.encryptedHmacKey = y.encryptedHmacKey; o.encryptedHmacValue = y.encryptedHmacValue; break;
|
||||
case '<keyEncryptors>': case '<keyEncryptors': o.encs = []; break;
|
||||
case '</keyEncryptors>': break;
|
||||
|
||||
case '<keyEncryptor': o.uri = y.uri; break;
|
||||
case '</keyEncryptor>': break;
|
||||
case '<encryptedKey': o.encs.push(y); break;
|
||||
default: throw y[0];
|
||||
}
|
||||
});
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* [MS-OFFCRYPTO] 2.3.5.1 RC4 CryptoAPI Encryption Header */
|
||||
function parse_RC4CryptoHeader(blob, length) {
|
||||
var o = {};
|
||||
@ -15191,7 +15208,12 @@ wb.opts.Date1904 = Workbook.WBProps.date1904 = val; break;
|
||||
sst = val;
|
||||
} break;
|
||||
case 'Format': { /* val = [id, fmt] */
|
||||
SSF.load(val[1], val[0]);
|
||||
if(opts.biff == 4) {
|
||||
BIFF2FmtTable[BIFF2Fmt++] = val[1];
|
||||
for(var b4idx = 0; b4idx < BIFF2Fmt + 163; ++b4idx) if(SSF._table[b4idx] == val[1]) break;
|
||||
if(b4idx >= 163) SSF.load(val[1], BIFF2Fmt + 163);
|
||||
}
|
||||
else SSF.load(val[1], val[0]);
|
||||
} break;
|
||||
case 'BIFF2FORMAT': {
|
||||
BIFF2FmtTable[BIFF2Fmt++] = val;
|
||||
@ -18246,40 +18268,41 @@ function parse_zip(zip, opts) {
|
||||
return out;
|
||||
}
|
||||
|
||||
/* references to [MS-OFFCRYPTO] */
|
||||
function parse_xlsxcfb(cfb, opts) {
|
||||
var f = 'Version';
|
||||
var data = CFB.find(cfb, f);
|
||||
if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
/* [MS-OFFCRYPTO] 2.1.1 */
|
||||
function parse_xlsxcfb(cfb, _opts) {
|
||||
var opts = _opts || {};
|
||||
var f = '/!DataSpaces/Version';
|
||||
var data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
var version = parse_DataSpaceVersionInfo(data.content);
|
||||
|
||||
/* 2.3.4.1 */
|
||||
f = 'DataSpaceMap';
|
||||
data = CFB.find(cfb, f);
|
||||
if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
f = '/!DataSpaces/DataSpaceMap';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
var dsm = parse_DataSpaceMap(data.content);
|
||||
if(dsm.length !== 1 || dsm[0].comps.length !== 1 || dsm[0].comps[0].t !== 0 || dsm[0].name !== "StrongEncryptionDataSpace" || dsm[0].comps[0].v !== "EncryptedPackage")
|
||||
throw new Error("ECMA-376 Encrypted file bad " + f);
|
||||
|
||||
f = 'StrongEncryptionDataSpace';
|
||||
data = CFB.find(cfb, f);
|
||||
if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
/* 2.3.4.2 */
|
||||
f = '/!DataSpaces/DataSpaceInfo/StrongEncryptionDataSpace';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
var seds = parse_DataSpaceDefinition(data.content);
|
||||
if(seds.length != 1 || seds[0] != "StrongEncryptionTransform")
|
||||
throw new Error("ECMA-376 Encrypted file bad " + f);
|
||||
|
||||
/* 2.3.4.3 */
|
||||
f = '!Primary';
|
||||
data = CFB.find(cfb, f);
|
||||
if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
f = '/!DataSpaces/TransformInfo/StrongEncryptionTransform/!Primary';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
var hdr = parse_Primary(data.content);
|
||||
|
||||
f = 'EncryptionInfo';
|
||||
data = CFB.find(cfb, f);
|
||||
if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
f = '/EncryptionInfo';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
var einfo = parse_EncryptionInfo(data.content);
|
||||
|
||||
if(einfo[0] == 0x04) throw new Error("File is password-protected: ECMA-376 Agile");
|
||||
/* 2.3.4.4 */
|
||||
f = '/EncryptedPackage';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
|
||||
if(einfo[0] == 0x04 && typeof decrypt_agile !== 'undefined') return decrypt_agile(einfo[1], data.content, opts.password || "", opts);
|
||||
throw new Error("File is password-protected");
|
||||
}
|
||||
|
||||
@ -18867,6 +18890,7 @@ var utils = {
|
||||
table_to_sheet: parse_dom_table,
|
||||
table_to_book: table_to_book,
|
||||
sheet_to_csv: sheet_to_csv,
|
||||
sheet_to_txt: sheet_to_txt,
|
||||
sheet_to_json: sheet_to_json,
|
||||
sheet_to_html: HTML_.from_sheet,
|
||||
sheet_to_formulae: sheet_to_formulae,
|
||||
|
20
dist/xlsx.min.js
vendored
20
dist/xlsx.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/xlsx.min.map
vendored
2
dist/xlsx.min.map
vendored
File diff suppressed because one or more lines are too long
@ -16,6 +16,7 @@ The [`demos` directory](demos/) includes sample projects for:
|
||||
- [`requirejs`](demos/requirejs/)
|
||||
- [`rollup`](demos/rollup/)
|
||||
- [`systemjs`](demos/systemjs/)
|
||||
- [`typescript`](demos/typescript/)
|
||||
- [`webpack 2.x`](demos/webpack/)
|
||||
|
||||
**Platforms and Integrations**
|
||||
|
@ -63,6 +63,7 @@ files and output the contents in various formats. The source is available at
|
||||
Some helper functions in `XLSX.utils` generate different views of the sheets:
|
||||
|
||||
- `XLSX.utils.sheet_to_csv` generates CSV
|
||||
- `XLSX.utils.sheet_to_txt` generates UTF16 Formatted Text
|
||||
- `XLSX.utils.sheet_to_html` generates HTML
|
||||
- `XLSX.utils.sheet_to_json` generates an array of objects
|
||||
- `XLSX.utils.sheet_to_formulae` generates a list of formulae
|
||||
|
@ -43,6 +43,7 @@ Utilities are available in the `XLSX.utils` object and are described in the
|
||||
|
||||
- `sheet_to_json` converts a worksheet object to an array of JSON objects.
|
||||
- `sheet_to_csv` generates delimiter-separated-values output.
|
||||
- `sheet_to_txt` generates UTF16 formatted text.
|
||||
- `sheet_to_html` generates HTML output.
|
||||
- `sheet_to_formulae` generates a list of the formulae (with value fallbacks).
|
||||
|
||||
|
@ -170,6 +170,8 @@ The `txt` output type uses the tab character as the field separator. If the
|
||||
`codepage` library is available (included in full distribution but not core),
|
||||
the output will be encoded in `CP1200` and the BOM will be prepended.
|
||||
|
||||
`XLSX.utils.sheet_to_txt` takes the same arguments as `sheet_to_csv`.
|
||||
|
||||
### HTML Output
|
||||
|
||||
As an alternative to the `writeFile` HTML type, `XLSX.utils.sheet_to_html` also
|
||||
|
@ -191,6 +191,7 @@ The [`demos` directory](demos/) includes sample projects for:
|
||||
- [`requirejs`](demos/requirejs/)
|
||||
- [`rollup`](demos/rollup/)
|
||||
- [`systemjs`](demos/systemjs/)
|
||||
- [`typescript`](demos/typescript/)
|
||||
- [`webpack 2.x`](demos/webpack/)
|
||||
|
||||
**Platforms and Integrations**
|
||||
@ -521,6 +522,7 @@ files and output the contents in various formats. The source is available at
|
||||
Some helper functions in `XLSX.utils` generate different views of the sheets:
|
||||
|
||||
- `XLSX.utils.sheet_to_csv` generates CSV
|
||||
- `XLSX.utils.sheet_to_txt` generates UTF16 Formatted Text
|
||||
- `XLSX.utils.sheet_to_html` generates HTML
|
||||
- `XLSX.utils.sheet_to_json` generates an array of objects
|
||||
- `XLSX.utils.sheet_to_formulae` generates a list of formulae
|
||||
@ -667,6 +669,7 @@ Utilities are available in the `XLSX.utils` object and are described in the
|
||||
|
||||
- `sheet_to_json` converts a worksheet object to an array of JSON objects.
|
||||
- `sheet_to_csv` generates delimiter-separated-values output.
|
||||
- `sheet_to_txt` generates UTF16 formatted text.
|
||||
- `sheet_to_html` generates HTML output.
|
||||
- `sheet_to_formulae` generates a list of the formulae (with value fallbacks).
|
||||
|
||||
@ -1700,6 +1703,8 @@ The `txt` output type uses the tab character as the field separator. If the
|
||||
`codepage` library is available (included in full distribution but not core),
|
||||
the output will be encoded in `CP1200` and the BOM will be prepended.
|
||||
|
||||
`XLSX.utils.sheet_to_txt` takes the same arguments as `sheet_to_csv`.
|
||||
|
||||
### HTML Output
|
||||
|
||||
As an alternative to the `writeFile` HTML type, `XLSX.utils.sheet_to_html` also
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xlsx",
|
||||
"version": "0.11.10",
|
||||
"version": "0.11.11",
|
||||
"author": "sheetjs",
|
||||
"description": "SheetJS Spreadsheet data parser and writer",
|
||||
"keywords": [
|
||||
@ -31,7 +31,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"adler-32": "~1.1.0",
|
||||
"cfb": "~1.0.0",
|
||||
"cfb": "~1.0.1",
|
||||
"codepage": "~1.11.0",
|
||||
"commander": "~2.11.0",
|
||||
"crc-32": "~1.1.1",
|
||||
|
3
types/index.d.ts
vendored
3
types/index.d.ts
vendored
@ -649,6 +649,9 @@ export interface XLSX$Utils {
|
||||
/** Generates delimiter-separated-values output */
|
||||
sheet_to_csv(worksheet: WorkSheet, options?: Sheet2CSVOpts): string;
|
||||
|
||||
/** Generates UTF16 Formatted Text */
|
||||
sheet_to_txt(worksheet: WorkSheet, options?: Sheet2CSVOpts): string;
|
||||
|
||||
/** Generates HTML */
|
||||
sheet_to_html(worksheet: WorkSheet, options?: Sheet2HTMLOpts): string;
|
||||
|
||||
|
@ -20,6 +20,7 @@ interface Tester {
|
||||
|
||||
const jsonvalues: Tester[] = XLSX.utils.sheet_to_json<Tester>(firstworksheet);
|
||||
const csv: string = XLSX.utils.sheet_to_csv(firstworksheet);
|
||||
const txt: string = XLSX.utils.sheet_to_txt(firstworksheet);
|
||||
const formulae: string[] = XLSX.utils.sheet_to_formulae(firstworksheet);
|
||||
const aoa: any[][] = XLSX.utils.sheet_to_json<any[]>(firstworksheet, {raw:true, header:1});
|
||||
|
||||
|
79
xlsx.flow.js
79
xlsx.flow.js
@ -4,7 +4,7 @@
|
||||
/*global global, exports, module, require:false, process:false, Buffer:false */
|
||||
var XLSX = {};
|
||||
(function make_xlsx(XLSX){
|
||||
XLSX.version = '0.11.10';
|
||||
XLSX.version = '0.11.11';
|
||||
var current_codepage = 1200;
|
||||
/*:: declare var cptable:any; */
|
||||
/*global cptable:true */
|
||||
@ -106,7 +106,7 @@ function s2a(s/*:string*/) {
|
||||
|
||||
var bconcat = function(bufs) { return [].concat.apply([], bufs); };
|
||||
|
||||
var chr0 = /\u0000/g, chr1 = /[\u0001-\u0006]/;
|
||||
var chr0 = /\u0000/g, chr1 = /[\u0001-\u0006]/g;
|
||||
/*::
|
||||
declare type Block = any;
|
||||
declare type BufArray = {
|
||||
@ -1089,7 +1089,7 @@ type CFBFiles = {[n:string]:CFBEntry};
|
||||
/* [MS-CFB] v20130118 */
|
||||
var CFB = (function _CFB(){
|
||||
var exports/*:CFBModule*/ = /*::(*/{}/*:: :any)*/;
|
||||
exports.version = '1.0.0';
|
||||
exports.version = '1.0.1';
|
||||
/* [MS-CFB] 2.6.4 */
|
||||
function namecmp(l/*:string*/, r/*:string*/)/*:number*/ {
|
||||
var L = l.split("/"), R = r.split("/");
|
||||
@ -6930,6 +6930,7 @@ function parse_DataSpaceMapEntry(blob) {
|
||||
}
|
||||
o.name = blob.read_shift(0, 'lpp4');
|
||||
o.comps = comps;
|
||||
if(blob.l != end) throw new Error("Bad DataSpaceMapEntry: " + blob.l + " != " + end);
|
||||
return o;
|
||||
}
|
||||
|
||||
@ -6958,7 +6959,7 @@ function parse_TransformInfoHeader(blob, length) {
|
||||
var tgt = blob.l + len - 4;
|
||||
blob.l += 4; // must be 0x1
|
||||
o.id = blob.read_shift(0, 'lpp4');
|
||||
// tgt == len
|
||||
if(tgt != blob.l) throw new Error("Bad TransformInfoHeader record: " + blob.l + " != " + tgt);
|
||||
o.name = blob.read_shift(0, 'lpp4');
|
||||
o.R = parse_CRYPTOVersion(blob, 4);
|
||||
o.U = parse_CRYPTOVersion(blob, 4);
|
||||
@ -7037,13 +7038,29 @@ function parse_EncInfoStd(blob, vers) {
|
||||
function parse_EncInfoExt(blob, vers) { throw new Error("File is password-protected: ECMA-376 Extensible"); }
|
||||
/* [MS-OFFCRYPTO] 2.3.4.10 EncryptionInfo Stream (Agile Encryption) */
|
||||
function parse_EncInfoAgl(blob, vers) {
|
||||
var KeyData = ["saltSize","blockSize","keyBits","hashSize","cipherAlgorithm","cipherChaining","hashAlgorithm","saltValue"];
|
||||
blob.l+=4;
|
||||
return blob.read_shift(blob.length - blob.l, 'utf8');
|
||||
var xml = blob.read_shift(blob.length - blob.l, 'utf8');
|
||||
var o = {};
|
||||
xml.replace(tagregex, function xml_agile(x, idx) {
|
||||
var y/*:any*/ = parsexmltag(x);
|
||||
switch(strip_ns(y[0])) {
|
||||
case '<?xml': break;
|
||||
case '<encryption': case '</encryption>': break;
|
||||
case '<keyData': KeyData.forEach(function(k) { o[k] = y[k]; }); break;
|
||||
case '<dataIntegrity': o.encryptedHmacKey = y.encryptedHmacKey; o.encryptedHmacValue = y.encryptedHmacValue; break;
|
||||
case '<keyEncryptors>': case '<keyEncryptors': o.encs = []; break;
|
||||
case '</keyEncryptors>': break;
|
||||
|
||||
case '<keyEncryptor': o.uri = y.uri; break;
|
||||
case '</keyEncryptor>': break;
|
||||
case '<encryptedKey': o.encs.push(y); break;
|
||||
default: throw y[0];
|
||||
}
|
||||
});
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* [MS-OFFCRYPTO] 2.3.5.1 RC4 CryptoAPI Encryption Header */
|
||||
function parse_RC4CryptoHeader(blob, length/*:number*/) {
|
||||
var o = {};
|
||||
@ -15291,7 +15308,12 @@ function parse_workbook(blob, options/*:ParseOpts*/)/*:Workbook*/ {
|
||||
sst = val;
|
||||
} break;
|
||||
case 'Format': { /* val = [id, fmt] */
|
||||
SSF.load(val[1], val[0]);
|
||||
if(opts.biff == 4) {
|
||||
BIFF2FmtTable[BIFF2Fmt++] = val[1];
|
||||
for(var b4idx = 0; b4idx < BIFF2Fmt + 163; ++b4idx) if(SSF._table[b4idx] == val[1]) break;
|
||||
if(b4idx >= 163) SSF.load(val[1], BIFF2Fmt + 163);
|
||||
}
|
||||
else SSF.load(val[1], val[0]);
|
||||
} break;
|
||||
case 'BIFF2FORMAT': {
|
||||
BIFF2FmtTable[BIFF2Fmt++] = val;
|
||||
@ -18348,40 +18370,42 @@ function parse_zip(zip/*:ZIP*/, opts/*:?ParseOpts*/)/*:Workbook*/ {
|
||||
return out;
|
||||
}
|
||||
|
||||
/* references to [MS-OFFCRYPTO] */
|
||||
function parse_xlsxcfb(cfb, opts/*:?ParseOpts*/)/*:Workbook*/ {
|
||||
var f = 'Version';
|
||||
var data = CFB.find(cfb, f);
|
||||
if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
/* [MS-OFFCRYPTO] 2.1.1 */
|
||||
function parse_xlsxcfb(cfb, _opts/*:?ParseOpts*/)/*:Workbook*/ {
|
||||
var opts = _opts || {};
|
||||
var f = '/!DataSpaces/Version';
|
||||
var data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
var version = parse_DataSpaceVersionInfo(data.content);
|
||||
|
||||
/* 2.3.4.1 */
|
||||
f = 'DataSpaceMap';
|
||||
data = CFB.find(cfb, f);
|
||||
if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
f = '/!DataSpaces/DataSpaceMap';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
var dsm = parse_DataSpaceMap(data.content);
|
||||
if(dsm.length !== 1 || dsm[0].comps.length !== 1 || dsm[0].comps[0].t !== 0 || dsm[0].name !== "StrongEncryptionDataSpace" || dsm[0].comps[0].v !== "EncryptedPackage")
|
||||
throw new Error("ECMA-376 Encrypted file bad " + f);
|
||||
|
||||
f = 'StrongEncryptionDataSpace';
|
||||
data = CFB.find(cfb, f);
|
||||
if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
/* 2.3.4.2 */
|
||||
f = '/!DataSpaces/DataSpaceInfo/StrongEncryptionDataSpace';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
var seds = parse_DataSpaceDefinition(data.content);
|
||||
if(seds.length != 1 || seds[0] != "StrongEncryptionTransform")
|
||||
throw new Error("ECMA-376 Encrypted file bad " + f);
|
||||
|
||||
/* 2.3.4.3 */
|
||||
f = '!Primary';
|
||||
data = CFB.find(cfb, f);
|
||||
if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
f = '/!DataSpaces/TransformInfo/StrongEncryptionTransform/!Primary';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
var hdr = parse_Primary(data.content);
|
||||
|
||||
f = 'EncryptionInfo';
|
||||
data = CFB.find(cfb, f);
|
||||
if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
f = '/EncryptionInfo';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
var einfo = parse_EncryptionInfo(data.content);
|
||||
|
||||
if(einfo[0] == 0x04) throw new Error("File is password-protected: ECMA-376 Agile");
|
||||
/* 2.3.4.4 */
|
||||
f = '/EncryptedPackage';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
|
||||
/*:: declare var decrypt_agile:any; */
|
||||
if(einfo[0] == 0x04 && typeof decrypt_agile !== 'undefined') return decrypt_agile(einfo[1], data.content, opts.password || "", opts);
|
||||
throw new Error("File is password-protected");
|
||||
}
|
||||
|
||||
@ -18972,6 +18996,7 @@ var utils/*:any*/ = {
|
||||
table_to_sheet: parse_dom_table,
|
||||
table_to_book: table_to_book,
|
||||
sheet_to_csv: sheet_to_csv,
|
||||
sheet_to_txt: sheet_to_txt,
|
||||
sheet_to_json: sheet_to_json,
|
||||
sheet_to_html: HTML_.from_sheet,
|
||||
sheet_to_formulae: sheet_to_formulae,
|
||||
|
78
xlsx.js
78
xlsx.js
@ -4,7 +4,7 @@
|
||||
/*global global, exports, module, require:false, process:false, Buffer:false */
|
||||
var XLSX = {};
|
||||
(function make_xlsx(XLSX){
|
||||
XLSX.version = '0.11.10';
|
||||
XLSX.version = '0.11.11';
|
||||
var current_codepage = 1200;
|
||||
/*global cptable:true */
|
||||
if(typeof module !== "undefined" && typeof require !== 'undefined') {
|
||||
@ -105,7 +105,7 @@ function s2a(s) {
|
||||
|
||||
var bconcat = function(bufs) { return [].concat.apply([], bufs); };
|
||||
|
||||
var chr0 = /\u0000/g, chr1 = /[\u0001-\u0006]/;
|
||||
var chr0 = /\u0000/g, chr1 = /[\u0001-\u0006]/g;
|
||||
/* ssf.js (C) 2013-present SheetJS -- http://sheetjs.com */
|
||||
/*jshint -W041 */
|
||||
var SSF = ({});
|
||||
@ -1026,7 +1026,7 @@ var DO_NOT_EXPORT_CFB = true;
|
||||
/* [MS-CFB] v20130118 */
|
||||
var CFB = (function _CFB(){
|
||||
var exports = {};
|
||||
exports.version = '1.0.0';
|
||||
exports.version = '1.0.1';
|
||||
/* [MS-CFB] 2.6.4 */
|
||||
function namecmp(l, r) {
|
||||
var L = l.split("/"), R = r.split("/");
|
||||
@ -6844,6 +6844,7 @@ function parse_DataSpaceMapEntry(blob) {
|
||||
}
|
||||
o.name = blob.read_shift(0, 'lpp4');
|
||||
o.comps = comps;
|
||||
if(blob.l != end) throw new Error("Bad DataSpaceMapEntry: " + blob.l + " != " + end);
|
||||
return o;
|
||||
}
|
||||
|
||||
@ -6872,7 +6873,7 @@ function parse_TransformInfoHeader(blob, length) {
|
||||
var tgt = blob.l + len - 4;
|
||||
blob.l += 4; // must be 0x1
|
||||
o.id = blob.read_shift(0, 'lpp4');
|
||||
// tgt == len
|
||||
if(tgt != blob.l) throw new Error("Bad TransformInfoHeader record: " + blob.l + " != " + tgt);
|
||||
o.name = blob.read_shift(0, 'lpp4');
|
||||
o.R = parse_CRYPTOVersion(blob, 4);
|
||||
o.U = parse_CRYPTOVersion(blob, 4);
|
||||
@ -6951,13 +6952,29 @@ function parse_EncInfoStd(blob, vers) {
|
||||
function parse_EncInfoExt(blob, vers) { throw new Error("File is password-protected: ECMA-376 Extensible"); }
|
||||
/* [MS-OFFCRYPTO] 2.3.4.10 EncryptionInfo Stream (Agile Encryption) */
|
||||
function parse_EncInfoAgl(blob, vers) {
|
||||
var KeyData = ["saltSize","blockSize","keyBits","hashSize","cipherAlgorithm","cipherChaining","hashAlgorithm","saltValue"];
|
||||
blob.l+=4;
|
||||
return blob.read_shift(blob.length - blob.l, 'utf8');
|
||||
var xml = blob.read_shift(blob.length - blob.l, 'utf8');
|
||||
var o = {};
|
||||
xml.replace(tagregex, function xml_agile(x, idx) {
|
||||
var y = parsexmltag(x);
|
||||
switch(strip_ns(y[0])) {
|
||||
case '<?xml': break;
|
||||
case '<encryption': case '</encryption>': break;
|
||||
case '<keyData': KeyData.forEach(function(k) { o[k] = y[k]; }); break;
|
||||
case '<dataIntegrity': o.encryptedHmacKey = y.encryptedHmacKey; o.encryptedHmacValue = y.encryptedHmacValue; break;
|
||||
case '<keyEncryptors>': case '<keyEncryptors': o.encs = []; break;
|
||||
case '</keyEncryptors>': break;
|
||||
|
||||
case '<keyEncryptor': o.uri = y.uri; break;
|
||||
case '</keyEncryptor>': break;
|
||||
case '<encryptedKey': o.encs.push(y); break;
|
||||
default: throw y[0];
|
||||
}
|
||||
});
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* [MS-OFFCRYPTO] 2.3.5.1 RC4 CryptoAPI Encryption Header */
|
||||
function parse_RC4CryptoHeader(blob, length) {
|
||||
var o = {};
|
||||
@ -15191,7 +15208,12 @@ wb.opts.Date1904 = Workbook.WBProps.date1904 = val; break;
|
||||
sst = val;
|
||||
} break;
|
||||
case 'Format': { /* val = [id, fmt] */
|
||||
SSF.load(val[1], val[0]);
|
||||
if(opts.biff == 4) {
|
||||
BIFF2FmtTable[BIFF2Fmt++] = val[1];
|
||||
for(var b4idx = 0; b4idx < BIFF2Fmt + 163; ++b4idx) if(SSF._table[b4idx] == val[1]) break;
|
||||
if(b4idx >= 163) SSF.load(val[1], BIFF2Fmt + 163);
|
||||
}
|
||||
else SSF.load(val[1], val[0]);
|
||||
} break;
|
||||
case 'BIFF2FORMAT': {
|
||||
BIFF2FmtTable[BIFF2Fmt++] = val;
|
||||
@ -18246,40 +18268,41 @@ function parse_zip(zip, opts) {
|
||||
return out;
|
||||
}
|
||||
|
||||
/* references to [MS-OFFCRYPTO] */
|
||||
function parse_xlsxcfb(cfb, opts) {
|
||||
var f = 'Version';
|
||||
var data = CFB.find(cfb, f);
|
||||
if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
/* [MS-OFFCRYPTO] 2.1.1 */
|
||||
function parse_xlsxcfb(cfb, _opts) {
|
||||
var opts = _opts || {};
|
||||
var f = '/!DataSpaces/Version';
|
||||
var data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
var version = parse_DataSpaceVersionInfo(data.content);
|
||||
|
||||
/* 2.3.4.1 */
|
||||
f = 'DataSpaceMap';
|
||||
data = CFB.find(cfb, f);
|
||||
if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
f = '/!DataSpaces/DataSpaceMap';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
var dsm = parse_DataSpaceMap(data.content);
|
||||
if(dsm.length !== 1 || dsm[0].comps.length !== 1 || dsm[0].comps[0].t !== 0 || dsm[0].name !== "StrongEncryptionDataSpace" || dsm[0].comps[0].v !== "EncryptedPackage")
|
||||
throw new Error("ECMA-376 Encrypted file bad " + f);
|
||||
|
||||
f = 'StrongEncryptionDataSpace';
|
||||
data = CFB.find(cfb, f);
|
||||
if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
/* 2.3.4.2 */
|
||||
f = '/!DataSpaces/DataSpaceInfo/StrongEncryptionDataSpace';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
var seds = parse_DataSpaceDefinition(data.content);
|
||||
if(seds.length != 1 || seds[0] != "StrongEncryptionTransform")
|
||||
throw new Error("ECMA-376 Encrypted file bad " + f);
|
||||
|
||||
/* 2.3.4.3 */
|
||||
f = '!Primary';
|
||||
data = CFB.find(cfb, f);
|
||||
if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
f = '/!DataSpaces/TransformInfo/StrongEncryptionTransform/!Primary';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
var hdr = parse_Primary(data.content);
|
||||
|
||||
f = 'EncryptionInfo';
|
||||
data = CFB.find(cfb, f);
|
||||
if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
f = '/EncryptionInfo';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
var einfo = parse_EncryptionInfo(data.content);
|
||||
|
||||
if(einfo[0] == 0x04) throw new Error("File is password-protected: ECMA-376 Agile");
|
||||
/* 2.3.4.4 */
|
||||
f = '/EncryptedPackage';
|
||||
data = CFB.find(cfb, f); if(!data || !data.content) throw new Error("ECMA-376 Encrypted file missing " + f);
|
||||
|
||||
if(einfo[0] == 0x04 && typeof decrypt_agile !== 'undefined') return decrypt_agile(einfo[1], data.content, opts.password || "", opts);
|
||||
throw new Error("File is password-protected");
|
||||
}
|
||||
|
||||
@ -18867,6 +18890,7 @@ var utils = {
|
||||
table_to_sheet: parse_dom_table,
|
||||
table_to_book: table_to_book,
|
||||
sheet_to_csv: sheet_to_csv,
|
||||
sheet_to_txt: sheet_to_txt,
|
||||
sheet_to_json: sheet_to_json,
|
||||
sheet_to_html: HTML_.from_sheet,
|
||||
sheet_to_formulae: sheet_to_formulae,
|
||||
|
Loading…
Reference in New Issue
Block a user