initial release of S [ci skip]

This commit is contained in:
SheetJS 2019-09-04 02:26:56 -04:00
parent 458575184d
commit e3c5eac99c
102 changed files with 2080 additions and 0 deletions

1
packages/s/.gitignore vendored Normal file

@ -0,0 +1 @@
.cache

8
packages/s/.npmignore Normal file

@ -0,0 +1,8 @@
.cache/
src/
misc/
tsconfig/
*.tgz
test.ts
Makefile
tsconfig.*

201
packages/s/LICENSE Normal file

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright (C) 2019-present SheetJS LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

23
packages/s/Makefile Normal file

@ -0,0 +1,23 @@
.PHONY: all
all: cjs esm mjs S types
.PHONY: cjs esm types
cjs esm types: %: ./tsconfig/tsconfig.%.json ./src/
@tsc -p ./tsconfig/tsconfig.$@.json
.PHONY: mjs
mjs: esm
@./misc/make_mjs.sh
.PHONY: S
S: cjs
@webpack-cli --config misc/webpack.config.js misc/standalone.js --output-filename S.js --display-modules --display-reasons --profile
.PHONY: test
test: mjs cjs S
@node misc/require_test.njs
@node --experimental-modules --es-module-specifier-resolution=node misc/import_test.mjs
@cp dist/S.js misc && node misc/puppetsta.js
@concurrently --kill-others -s first "http-server -s -p 7262" "node misc/puppetmjs.js"
@parcel build misc/parcel.html -d misc/parcel -o parcelout.html --public-url "./" && node misc/puppetpcl.js
@mocha -r ts-node/register test.ts

12
packages/s/README.md Normal file

@ -0,0 +1,12 @@
# s
TypeScript/JavaScript wrapper closely aligned with the OfficeJS Excel API in the
MIT-licensed <https://github.com/OfficeDev/office-js-docs-reference>
The `1.x.x` releases should not be treated as stable. `0.x.x` releases serve to
preserve the original use of the `S` module.
## License
Please consult the attached LICENSE file for details. All rights not explicitly
granted by the Apache 2.0 License are reserved by the Original Author.

11
packages/s/dist/S.js vendored Normal file

@ -0,0 +1,11 @@
var S=function(t){var e={};function r(o){if(e[o])return e[o].exports;var n=e[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=t,r.c=e,r.d=function(t,e,o){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(o,n,function(e){return t[e]}.bind(null,n));return o},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){var o=r(1);t.exports=o},function(t,e,r){"use strict";
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
let o;function n(){return o}function s(t){o=t}r.r(e),"undefined"!=typeof XLSX&&(o=XLSX);
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
class i{constructor(t){this._wb=t}}
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
class u{constructor(t){this._name=t}get raw(){return this._name}}
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
class a{constructor(t){this._wb=t}get items(){return this._wb.Workbook&&this._wb.Workbook.Names?this._wb.Workbook.Names.filter(t=>{t.Sheet}).map(t=>new u(t)):[]}getName(t){if(this._wb.Workbook&&this._wb.Workbook.Names){const e=this._wb.Workbook.Names;for(let r=0;r<e.length;++r)if(e[r].Name.toLowerCase()==t.toLowerCase()&&null==e[r].Sheet)return new u(e[r])}throw new Error(`Cannot find defined name |${t}|`)}get count(){return this._wb.Workbook&&this._wb.Workbook.Names?this._wb.Workbook.Names.filter(t=>{t.Sheet}).length:0}add(t,e,r){try{return this.getName(t)}catch(o){const n={Name:t,Ref:e.toString(),Comment:r||""};return this._wb.Workbook||(this._wb.Workbook={}),this._wb.Workbook.Names||(this._wb.Workbook.Names=[]),this._wb.Workbook.Names.push(n),new u(n)}}}
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
class b{constructor(t){this._wb=t||n().utils.book_new(),this._ws=new i(this._wb),this._names=new a(this._wb)}get wb(){return this._wb}get names(){return this._names}get worksheets(){return this._ws}}r.d(e,"Workbook",function(){return b}),r.d(e,"get_XLSX",function(){return n}),r.d(e,"set_XLSX",function(){return s})}]);

10
packages/s/dist/cjs/index.js vendored Normal file

@ -0,0 +1,10 @@
"use strict";
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
Object.defineProperty(exports, "__esModule", { value: true });
var Workbook_1 = require("./s/Workbook");
exports.Workbook = Workbook_1.Workbook;
var XLSXWrapper_1 = require("./s/XLSXWrapper");
exports.get_XLSX = XLSXWrapper_1.get_XLSX;
exports.set_XLSX = XLSXWrapper_1.set_XLSX;
//# sourceMappingURL=index.js.map

1
packages/s/dist/cjs/index.js.map vendored Normal file

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":";AAAA,2DAA2D;AAC3D,oBAAoB;;AAEpB,yCAAwC;AAA/B,8BAAA,QAAQ,CAAA;AACjB,+CAAqD;AAA5C,iCAAA,QAAQ,CAAA;AAAE,iCAAA,QAAQ,CAAA"}

12
packages/s/dist/cjs/s/Range.js vendored Normal file

@ -0,0 +1,12 @@
"use strict";
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
Object.defineProperty(exports, "__esModule", { value: true });
var Range = /** @class */ (function () {
function Range() {
}
return Range;
}());
exports.Range = Range;
;
//# sourceMappingURL=Range.js.map

1
packages/s/dist/cjs/s/Range.js.map vendored Normal file

@ -0,0 +1 @@
{"version":3,"file":"Range.js","sourceRoot":"../src/","sources":["s/Range.ts"],"names":[],"mappings":";AAAA,2DAA2D;AAC3D,oBAAoB;;AAEpB;IAAA;IACA,CAAC;IAAD,YAAC;AAAD,CAAC,AADD,IACC;AADY,sBAAK;AACjB,CAAC"}

37
packages/s/dist/cjs/s/Workbook.js vendored Normal file

@ -0,0 +1,37 @@
"use strict";
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
Object.defineProperty(exports, "__esModule", { value: true });
/// <reference path="../xlsx.d.ts"/>
var XLSXWrapper_1 = require("./XLSXWrapper");
var WorksheetCollection_1 = require("./worksheet/WorksheetCollection");
var WorkbookDefinedNameCollection_1 = require("./names/WorkbookDefinedNameCollection");
var Workbook = /** @class */ (function () {
function Workbook(wb) {
this._wb = wb || XLSXWrapper_1.get_XLSX().utils.book_new();
this._ws = new WorksheetCollection_1.WorksheetCollection(this._wb);
this._names = new WorkbookDefinedNameCollection_1.WorkbookDefinedNameCollection(this._wb);
}
;
Object.defineProperty(Workbook.prototype, "wb", {
get: function () { return this._wb; },
enumerable: true,
configurable: true
});
;
Object.defineProperty(Workbook.prototype, "names", {
get: function () { return this._names; },
enumerable: true,
configurable: true
});
Object.defineProperty(Workbook.prototype, "worksheets", {
get: function () { return this._ws; },
enumerable: true,
configurable: true
});
;
return Workbook;
}());
exports.Workbook = Workbook;
;
//# sourceMappingURL=Workbook.js.map

1
packages/s/dist/cjs/s/Workbook.js.map vendored Normal file

@ -0,0 +1 @@
{"version":3,"file":"Workbook.js","sourceRoot":"../src/","sources":["s/Workbook.ts"],"names":[],"mappings":";AAAA,2DAA2D;AAC3D,oBAAoB;;AAEpB,oCAAoC;AAEpC,6CAAyC;AACzC,uEAAsE;AAEtE,uFAAsF;AAEtF;IAKE,kBAAY,EAAkB;QAC5B,IAAI,CAAC,GAAG,GAAG,EAAE,IAAI,sBAAQ,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC7C,IAAI,CAAC,GAAG,GAAG,IAAI,yCAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM,GAAG,IAAI,6DAA6B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5D,CAAC;IAAA,CAAC;IAEF,sBAAI,wBAAE;aAAN,cAA0B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;;;OAAA;IAAA,CAAC;IAE7C,sBAAI,2BAAK;aAAT,cAAqC,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;;;OAAA;IAE1D,sBAAI,gCAAU;aAAd,cAAwC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;;;OAAA;IAAA,CAAC;IAE7D,eAAC;AAAD,CAAC,AAjBD,IAiBC;AAjBY,4BAAQ;AAiBpB,CAAC"}

15
packages/s/dist/cjs/s/XLSXWrapper.js vendored Normal file

@ -0,0 +1,15 @@
"use strict";
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
Object.defineProperty(exports, "__esModule", { value: true });
/// <reference path="../xlsx.d.ts"/>
var _XLSX;
if (typeof XLSX !== "undefined")
_XLSX = XLSX;
function get_XLSX() { return _XLSX; }
exports.get_XLSX = get_XLSX;
;
function set_XLSX(xlsx) { _XLSX = xlsx; }
exports.set_XLSX = set_XLSX;
;
//# sourceMappingURL=XLSXWrapper.js.map

@ -0,0 +1 @@
{"version":3,"file":"XLSXWrapper.js","sourceRoot":"../src/","sources":["s/XLSXWrapper.ts"],"names":[],"mappings":";AAAA,2DAA2D;AAC3D,oBAAoB;;AAEpB,oCAAoC;AAEpC,IAAI,KAAkB,CAAC;AACvB,IAAG,OAAO,IAAI,KAAK,WAAW;IAAE,KAAK,GAAG,IAAI,CAAC;AAE7C,SAAgB,QAAQ,KAAK,OAAO,KAAK,CAAC,CAAC,CAAC;AAA5C,4BAA4C;AAAA,CAAC;AAC7C,SAAgB,QAAQ,CAAC,IAAiB,IAAI,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC;AAA7D,4BAA6D;AAAA,CAAC"}

@ -0,0 +1,21 @@
"use strict";
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
Object.defineProperty(exports, "__esModule", { value: true });
/// <reference path="../../xlsx.d.ts"/>
var DefinedName = /** @class */ (function () {
function DefinedName(name) {
this._name = name;
}
;
Object.defineProperty(DefinedName.prototype, "raw", {
get: function () { return this._name; },
enumerable: true,
configurable: true
});
;
return DefinedName;
}());
exports.DefinedName = DefinedName;
;
//# sourceMappingURL=DefinedName.js.map

@ -0,0 +1 @@
{"version":3,"file":"DefinedName.js","sourceRoot":"../src/","sources":["s/names/DefinedName.ts"],"names":[],"mappings":";AAAA,2DAA2D;AAC3D,oBAAoB;;AAEpB,uCAAuC;AAEvC;IAGE,qBAAY,IAAsB;QAChC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAAA,CAAC;IAEF,sBAAI,4BAAG;aAAP,cAA8B,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;;;OAAA;IAAA,CAAC;IAErD,kBAAC;AAAD,CAAC,AATD,IASC;AATY,kCAAW;AASvB,CAAC"}

@ -0,0 +1,6 @@
"use strict";
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
Object.defineProperty(exports, "__esModule", { value: true });
;
//# sourceMappingURL=DefinedNameCollection.js.map

@ -0,0 +1 @@
{"version":3,"file":"DefinedNameCollection.js","sourceRoot":"../src/","sources":["s/names/DefinedNameCollection.ts"],"names":[],"mappings":";AAAA,2DAA2D;AAC3D,oBAAoB;;AAUnB,CAAC"}

@ -0,0 +1,81 @@
"use strict";
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
Object.defineProperty(exports, "__esModule", { value: true });
var DefinedName_1 = require("./DefinedName");
//import { Range } from "../Range";
var WorkbookDefinedNameCollection = /** @class */ (function () {
function WorkbookDefinedNameCollection(wb) {
this._wb = wb;
}
;
Object.defineProperty(WorkbookDefinedNameCollection.prototype, "items", {
/**
* Get read-only array of global defined names
*/
get: function () {
if (!this._wb.Workbook)
return [];
if (!this._wb.Workbook.Names)
return [];
return this._wb.Workbook.Names.filter(function (name) { name.Sheet == null; }).map(function (name) { return new DefinedName_1.DefinedName(name); });
},
enumerable: true,
configurable: true
});
;
/**
* Get defined name object
*/
WorkbookDefinedNameCollection.prototype.getName = function (name) {
if (this._wb.Workbook && this._wb.Workbook.Names) {
var names = this._wb.Workbook.Names;
for (var i = 0; i < names.length; ++i) {
if (names[i].Name.toLowerCase() != name.toLowerCase())
continue;
if (names[i].Sheet != null)
continue;
return new DefinedName_1.DefinedName(names[i]);
}
}
throw new Error("Cannot find defined name |" + name + "|");
};
Object.defineProperty(WorkbookDefinedNameCollection.prototype, "count", {
/**
* Number of global defined names
*/
get: function () {
if (!this._wb.Workbook)
return 0;
if (!this._wb.Workbook.Names)
return 0;
return this._wb.Workbook.Names.filter(function (name) { typeof name.Sheet == "undefined"; }).length;
},
enumerable: true,
configurable: true
});
/**
* Add or update defined name
* @param name String name
* @param ref Range object or string range/formula
* @param comment Optional comment
*/
WorkbookDefinedNameCollection.prototype.add = function (name, ref /*TODO: | Range */, comment) {
try {
return this.getName(name);
}
catch (e) {
var nm = { Name: name, Ref: ref.toString(), Comment: comment || "" };
if (!this._wb.Workbook)
this._wb.Workbook = {};
if (!this._wb.Workbook.Names)
this._wb.Workbook.Names = [];
this._wb.Workbook.Names.push(nm);
return new DefinedName_1.DefinedName(nm);
}
};
return WorkbookDefinedNameCollection;
}());
exports.WorkbookDefinedNameCollection = WorkbookDefinedNameCollection;
;
//# sourceMappingURL=WorkbookDefinedNameCollection.js.map

@ -0,0 +1 @@
{"version":3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IACH,CAAC;IACH,oCAAC;AAAD,CAAC,AAzDD,IAyDC;AAzDY,sEAA6B;AAyDzC,CAAC"}

@ -0,0 +1,15 @@
"use strict";
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
Object.defineProperty(exports, "__esModule", { value: true });
/// <reference path="../../xlsx.d.ts"/>
var WorksheetCollection = /** @class */ (function () {
function WorksheetCollection(wb) {
this._wb = wb;
}
;
return WorksheetCollection;
}());
exports.WorksheetCollection = WorksheetCollection;
;
//# sourceMappingURL=WorksheetCollection.js.map

@ -0,0 +1 @@
{"version":3,"file":"WorksheetCollection.js","sourceRoot":"../src/","sources":["s/worksheet/WorksheetCollection.ts"],"names":[],"mappings":";AAAA,2DAA2D;AAC3D,oBAAoB;;AAEpB,uCAAuC;AAEvC;IAGE,6BAAY,EAAiB;QAC3B,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;IAChB,CAAC;IAAA,CAAC;IACJ,0BAAC;AAAD,CAAC,AAND,IAMC;AANY,kDAAmB;AAM/B,CAAC"}

9
packages/s/dist/cjs/umd.js vendored Normal file

@ -0,0 +1,9 @@
"use strict";
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./index"));
//# sourceMappingURL=umd.js.map

1
packages/s/dist/cjs/umd.js.map vendored Normal file

@ -0,0 +1 @@
{"version":3,"file":"umd.js","sourceRoot":"../src/","sources":["umd.ts"],"names":[],"mappings":";AAAA,2DAA2D;AAC3D,oBAAoB;;;;;AAEpB,6BAAwB"}

5
packages/s/dist/esm/index.js vendored Normal file

@ -0,0 +1,5 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
export { Workbook } from "./s/Workbook";
export { get_XLSX, set_XLSX } from "./s/XLSXWrapper";
//# sourceMappingURL=index.js.map

1
packages/s/dist/esm/index.js.map vendored Normal file

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC"}

6
packages/s/dist/esm/s/Range.js vendored Normal file

@ -0,0 +1,6 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
export class Range {
}
;
//# sourceMappingURL=Range.js.map

1
packages/s/dist/esm/s/Range.js.map vendored Normal file

@ -0,0 +1 @@
{"version":3,"file":"Range.js","sourceRoot":"../src/","sources":["s/Range.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,MAAM,OAAO,KAAK;CACjB;AAAA,CAAC"}

21
packages/s/dist/esm/s/Workbook.js vendored Normal file

@ -0,0 +1,21 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
/// <reference path="../xlsx.d.ts"/>
import { get_XLSX } from "./XLSXWrapper";
import { WorksheetCollection } from "./worksheet/WorksheetCollection";
import { WorkbookDefinedNameCollection } from "./names/WorkbookDefinedNameCollection";
export class Workbook {
constructor(wb) {
this._wb = wb || get_XLSX().utils.book_new();
this._ws = new WorksheetCollection(this._wb);
this._names = new WorkbookDefinedNameCollection(this._wb);
}
;
get wb() { return this._wb; }
;
get names() { return this._names; }
get worksheets() { return this._ws; }
;
}
;
//# sourceMappingURL=Workbook.js.map

1
packages/s/dist/esm/s/Workbook.js.map vendored Normal file

@ -0,0 +1 @@
{"version":3,"file":"Workbook.js","sourceRoot":"../src/","sources":["s/Workbook.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,oCAAoC;AAEpC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEtE,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AAEtF,MAAM,OAAO,QAAQ;IAKnB,YAAY,EAAkB;QAC5B,IAAI,CAAC,GAAG,GAAG,EAAE,IAAI,QAAQ,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC7C,IAAI,CAAC,GAAG,GAAG,IAAI,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM,GAAG,IAAI,6BAA6B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5D,CAAC;IAAA,CAAC;IAEF,IAAI,EAAE,KAAoB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAAA,CAAC;IAE7C,IAAI,KAAK,KAA4B,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAE1D,IAAI,UAAU,KAA0B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAAA,CAAC;CAE5D;AAAA,CAAC"}

11
packages/s/dist/esm/s/XLSXWrapper.js vendored Normal file

@ -0,0 +1,11 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
/// <reference path="../xlsx.d.ts"/>
let _XLSX;
if (typeof XLSX !== "undefined")
_XLSX = XLSX;
export function get_XLSX() { return _XLSX; }
;
export function set_XLSX(xlsx) { _XLSX = xlsx; }
;
//# sourceMappingURL=XLSXWrapper.js.map

@ -0,0 +1 @@
{"version":3,"file":"XLSXWrapper.js","sourceRoot":"../src/","sources":["s/XLSXWrapper.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,oCAAoC;AAEpC,IAAI,KAAkB,CAAC;AACvB,IAAG,OAAO,IAAI,KAAK,WAAW;IAAE,KAAK,GAAG,IAAI,CAAC;AAE7C,MAAM,UAAU,QAAQ,KAAK,OAAO,KAAK,CAAC,CAAC,CAAC;AAAA,CAAC;AAC7C,MAAM,UAAU,QAAQ,CAAC,IAAiB,IAAI,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC;AAAA,CAAC"}

@ -0,0 +1,13 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
/// <reference path="../../xlsx.d.ts"/>
export class DefinedName {
constructor(name) {
this._name = name;
}
;
get raw() { return this._name; }
;
}
;
//# sourceMappingURL=DefinedName.js.map

@ -0,0 +1 @@
{"version":3,"file":"DefinedName.js","sourceRoot":"../src/","sources":["s/names/DefinedName.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,uCAAuC;AAEvC,MAAM,OAAO,WAAW;IAGtB,YAAY,IAAsB;QAChC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAAA,CAAC;IAEF,IAAI,GAAG,KAAuB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAAA,CAAC;CAEpD;AAAA,CAAC"}

@ -0,0 +1,4 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
;
//# sourceMappingURL=DefinedNameCollection.js.map

@ -0,0 +1 @@
{"version":3,"file":"DefinedNameCollection.js","sourceRoot":"../src/","sources":["s/names/DefinedNameCollection.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAUnB,CAAC"}

@ -0,0 +1,69 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
import { DefinedName } from "./DefinedName";
//import { Range } from "../Range";
export class WorkbookDefinedNameCollection {
constructor(wb) {
this._wb = wb;
}
;
/**
* Get read-only array of global defined names
*/
get items() {
if (!this._wb.Workbook)
return [];
if (!this._wb.Workbook.Names)
return [];
return this._wb.Workbook.Names.filter((name) => { name.Sheet == null; }).map((name) => new DefinedName(name));
}
;
/**
* Get defined name object
*/
getName(name) {
if (this._wb.Workbook && this._wb.Workbook.Names) {
const names = this._wb.Workbook.Names;
for (let i = 0; i < names.length; ++i) {
if (names[i].Name.toLowerCase() != name.toLowerCase())
continue;
if (names[i].Sheet != null)
continue;
return new DefinedName(names[i]);
}
}
throw new Error(`Cannot find defined name |${name}|`);
}
/**
* Number of global defined names
*/
get count() {
if (!this._wb.Workbook)
return 0;
if (!this._wb.Workbook.Names)
return 0;
return this._wb.Workbook.Names.filter((name) => { typeof name.Sheet == "undefined"; }).length;
}
/**
* Add or update defined name
* @param name String name
* @param ref Range object or string range/formula
* @param comment Optional comment
*/
add(name, ref /*TODO: | Range */, comment) {
try {
return this.getName(name);
}
catch (e) {
const nm = { Name: name, Ref: ref.toString(), Comment: comment || "" };
if (!this._wb.Workbook)
this._wb.Workbook = {};
if (!this._wb.Workbook.Names)
this._wb.Workbook.Names = [];
this._wb.Workbook.Names.push(nm);
return new DefinedName(nm);
}
}
}
;
//# sourceMappingURL=WorkbookDefinedNameCollection.js.map

@ -0,0 +1 @@
{"version":3,"file":"WorkbookDefinedNameCollection.js","sourceRoot":"../src/","sources":["s/names/WorkbookDefinedNameCollection.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAKpB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,mCAAmC;AAEnC,MAAM,OAAO,6BAA6B;IAGxC,YAAY,EAAiB;QAC3B,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;IAChB,CAAC;IAAA,CAAC;IAEF;;OAEG;IACH,IAAI,KAAK;QACP,IAAG,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ;YAAE,OAAO,EAAE,CAAC;QACjC,IAAG,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK;YAAE,OAAO,EAAE,CAAC;QACvC,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,GAAE,IAAI,CAAC,KAAK,IAAI,IAAI,CAAA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AAgB;QAChE,IAAI;YACF,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAC3B;QAAC,OAAM,CAAC,EAAE;YACT,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,CAAC;YACvE,IAAG,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ;gBAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,EAAE,CAAC;YAC9C,IAAG,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK;gBAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,GAAG,EAAE,CAAC;YAC1D,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACjC,OAAO,IAAI,WAAW,CAAC,EAAE,CAAC,CAAC;SAC5B;IACH,CAAC;CACF;AAAA,CAAC"}

@ -0,0 +1,11 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
/// <reference path="../../xlsx.d.ts"/>
export class WorksheetCollection {
constructor(wb) {
this._wb = wb;
}
;
}
;
//# sourceMappingURL=WorksheetCollection.js.map

@ -0,0 +1 @@
{"version":3,"file":"WorksheetCollection.js","sourceRoot":"../src/","sources":["s/worksheet/WorksheetCollection.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,uCAAuC;AAEvC,MAAM,OAAO,mBAAmB;IAG9B,YAAY,EAAiB;QAC3B,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;IAChB,CAAC;IAAA,CAAC;CACH;AAAA,CAAC"}

4
packages/s/dist/esm/umd.js vendored Normal file

@ -0,0 +1,4 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
export * from "./index";
//# sourceMappingURL=umd.js.map

1
packages/s/dist/esm/umd.js.map vendored Normal file

@ -0,0 +1 @@
{"version":3,"file":"umd.js","sourceRoot":"../src/","sources":["umd.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,cAAc,SAAS,CAAC"}

1
packages/s/dist/mjs/index.js.map vendored Normal file

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC"}

5
packages/s/dist/mjs/index.mjs vendored Normal file

@ -0,0 +1,5 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
export { Workbook } from "./s/Workbook.mjs";
export { get_XLSX, set_XLSX } from "./s/XLSXWrapper.mjs";
//# sourceMappingURL=index.js.map

1
packages/s/dist/mjs/s/Range.js.map vendored Normal file

@ -0,0 +1 @@
{"version":3,"file":"Range.js","sourceRoot":"../src/","sources":["s/Range.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,MAAM,OAAO,KAAK;CACjB;AAAA,CAAC"}

6
packages/s/dist/mjs/s/Range.mjs vendored Normal file

@ -0,0 +1,6 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
export class Range {
}
;
//# sourceMappingURL=Range.js.map

1
packages/s/dist/mjs/s/Workbook.js.map vendored Normal file

@ -0,0 +1 @@
{"version":3,"file":"Workbook.js","sourceRoot":"../src/","sources":["s/Workbook.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,oCAAoC;AAEpC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEtE,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AAEtF,MAAM,OAAO,QAAQ;IAKnB,YAAY,EAAkB;QAC5B,IAAI,CAAC,GAAG,GAAG,EAAE,IAAI,QAAQ,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC7C,IAAI,CAAC,GAAG,GAAG,IAAI,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM,GAAG,IAAI,6BAA6B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5D,CAAC;IAAA,CAAC;IAEF,IAAI,EAAE,KAAoB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAAA,CAAC;IAE7C,IAAI,KAAK,KAA4B,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAE1D,IAAI,UAAU,KAA0B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAAA,CAAC;CAE5D;AAAA,CAAC"}

21
packages/s/dist/mjs/s/Workbook.mjs vendored Normal file

@ -0,0 +1,21 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
/// <reference path="../xlsx.d.ts"/>
import { get_XLSX } from "./XLSXWrapper.mjs";
import { WorksheetCollection } from "./worksheet/WorksheetCollection.mjs";
import { WorkbookDefinedNameCollection } from "./names/WorkbookDefinedNameCollection.mjs";
export class Workbook {
constructor(wb) {
this._wb = wb || get_XLSX().utils.book_new();
this._ws = new WorksheetCollection(this._wb);
this._names = new WorkbookDefinedNameCollection(this._wb);
}
;
get wb() { return this._wb; }
;
get names() { return this._names; }
get worksheets() { return this._ws; }
;
}
;
//# sourceMappingURL=Workbook.js.map

@ -0,0 +1 @@
{"version":3,"file":"XLSXWrapper.js","sourceRoot":"../src/","sources":["s/XLSXWrapper.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,oCAAoC;AAEpC,IAAI,KAAkB,CAAC;AACvB,IAAG,OAAO,IAAI,KAAK,WAAW;IAAE,KAAK,GAAG,IAAI,CAAC;AAE7C,MAAM,UAAU,QAAQ,KAAK,OAAO,KAAK,CAAC,CAAC,CAAC;AAAA,CAAC;AAC7C,MAAM,UAAU,QAAQ,CAAC,IAAiB,IAAI,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC;AAAA,CAAC"}

11
packages/s/dist/mjs/s/XLSXWrapper.mjs vendored Normal file

@ -0,0 +1,11 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
/// <reference path="../xlsx.d.ts"/>
let _XLSX;
if (typeof XLSX !== "undefined")
_XLSX = XLSX;
export function get_XLSX() { return _XLSX; }
;
export function set_XLSX(xlsx) { _XLSX = xlsx; }
;
//# sourceMappingURL=XLSXWrapper.js.map

@ -0,0 +1 @@
{"version":3,"file":"DefinedName.js","sourceRoot":"../src/","sources":["s/names/DefinedName.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,uCAAuC;AAEvC,MAAM,OAAO,WAAW;IAGtB,YAAY,IAAsB;QAChC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAAA,CAAC;IAEF,IAAI,GAAG,KAAuB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAAA,CAAC;CAEpD;AAAA,CAAC"}

@ -0,0 +1,13 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
/// <reference path="../../xlsx.d.ts"/>
export class DefinedName {
constructor(name) {
this._name = name;
}
;
get raw() { return this._name; }
;
}
;
//# sourceMappingURL=DefinedName.js.map

@ -0,0 +1 @@
{"version":3,"file":"DefinedNameCollection.js","sourceRoot":"../src/","sources":["s/names/DefinedNameCollection.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAUnB,CAAC"}

@ -0,0 +1,4 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
;
//# sourceMappingURL=DefinedNameCollection.js.map

@ -0,0 +1 @@
{"version":3,"file":"WorkbookDefinedNameCollection.js","sourceRoot":"../src/","sources":["s/names/WorkbookDefinedNameCollection.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAKpB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,mCAAmC;AAEnC,MAAM,OAAO,6BAA6B;IAGxC,YAAY,EAAiB;QAC3B,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;IAChB,CAAC;IAAA,CAAC;IAEF;;OAEG;IACH,IAAI,KAAK;QACP,IAAG,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ;YAAE,OAAO,EAAE,CAAC;QACjC,IAAG,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK;YAAE,OAAO,EAAE,CAAC;QACvC,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,GAAE,IAAI,CAAC,KAAK,IAAI,IAAI,CAAA,CAAA,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7G,CAAC;IAAA,CAAC;IAEF;;OAEG;IACH,OAAO,CAAC,IAAY;QAClB,IAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE;YAC/C,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC;YACtC,KAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;gBACpC,IAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,IAAI,CAAC,WAAW,EAAE;oB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CAAC,EAAE,CAAC,CAAC;YACjC,OAAO,IAAI,WAAW,CAAC,EAAE,CAAC,CAAC;SAC5B;IACH,CAAC;CACF;AAAA,CAAC"}

@ -0,0 +1,69 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
import { DefinedName } from "./DefinedName.mjs";
//import { Range } from "../Range.mjs";
export class WorkbookDefinedNameCollection {
constructor(wb) {
this._wb = wb;
}
;
/**
* Get read-only array of global defined names
*/
get items() {
if (!this._wb.Workbook)
return [];
if (!this._wb.Workbook.Names)
return [];
return this._wb.Workbook.Names.filter((name) => { name.Sheet == null; }).map((name) => new DefinedName(name));
}
;
/**
* Get defined name object
*/
getName(name) {
if (this._wb.Workbook && this._wb.Workbook.Names) {
const names = this._wb.Workbook.Names;
for (let i = 0; i < names.length; ++i) {
if (names[i].Name.toLowerCase() != name.toLowerCase())
continue;
if (names[i].Sheet != null)
continue;
return new DefinedName(names[i]);
}
}
throw new Error(`Cannot find defined name |${name}|`);
}
/**
* Number of global defined names
*/
get count() {
if (!this._wb.Workbook)
return 0;
if (!this._wb.Workbook.Names)
return 0;
return this._wb.Workbook.Names.filter((name) => { typeof name.Sheet == "undefined"; }).length;
}
/**
* Add or update defined name
* @param name String name
* @param ref Range object or string range/formula
* @param comment Optional comment
*/
add(name, ref /*TODO: | Range */, comment) {
try {
return this.getName(name);
}
catch (e) {
const nm = { Name: name, Ref: ref.toString(), Comment: comment || "" };
if (!this._wb.Workbook)
this._wb.Workbook = {};
if (!this._wb.Workbook.Names)
this._wb.Workbook.Names = [];
this._wb.Workbook.Names.push(nm);
return new DefinedName(nm);
}
}
}
;
//# sourceMappingURL=WorkbookDefinedNameCollection.js.map

@ -0,0 +1 @@
{"version":3,"file":"WorksheetCollection.js","sourceRoot":"../src/","sources":["s/worksheet/WorksheetCollection.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,uCAAuC;AAEvC,MAAM,OAAO,mBAAmB;IAG9B,YAAY,EAAiB;QAC3B,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;IAChB,CAAC;IAAA,CAAC;CACH;AAAA,CAAC"}

@ -0,0 +1,11 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
/// <reference path="../../xlsx.d.ts"/>
export class WorksheetCollection {
constructor(wb) {
this._wb = wb;
}
;
}
;
//# sourceMappingURL=WorksheetCollection.js.map

1
packages/s/dist/mjs/umd.js.map vendored Normal file

@ -0,0 +1 @@
{"version":3,"file":"umd.js","sourceRoot":"../src/","sources":["umd.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,oBAAoB;AAEpB,cAAc,SAAS,CAAC"}

4
packages/s/dist/mjs/umd.mjs vendored Normal file

@ -0,0 +1,4 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
export * from "./index.mjs";
//# sourceMappingURL=umd.js.map

3
packages/s/dist/typings/index.d.ts vendored Normal file

@ -0,0 +1,3 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
export { Workbook } from "./s/Workbook";
export { get_XLSX, set_XLSX } from "./s/XLSXWrapper";

3
packages/s/dist/typings/s/Range.d.ts vendored Normal file

@ -0,0 +1,3 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
export declare class Range {
}

13
packages/s/dist/typings/s/Workbook.d.ts vendored Normal file

@ -0,0 +1,13 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/// <reference path="../../../src/xlsx.d.ts" />
import { WorksheetCollection } from "./worksheet/WorksheetCollection";
import { DefinedNameCollection } from "./names/DefinedNameCollection";
export declare class Workbook {
private readonly _wb;
private readonly _ws;
private readonly _names;
constructor(wb?: XLSX.WorkBook);
readonly wb: XLSX.WorkBook;
readonly names: DefinedNameCollection;
readonly worksheets: WorksheetCollection;
}

@ -0,0 +1,4 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/// <reference path="../../../src/xlsx.d.ts" />
export declare function get_XLSX(): typeof XLSX;
export declare function set_XLSX(xlsx: typeof XLSX): void;

@ -0,0 +1,7 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/// <reference path="../../../../src/xlsx.d.ts" />
export declare class DefinedName {
readonly _name: XLSX.DefinedName;
constructor(name: XLSX.DefinedName);
readonly raw: XLSX.DefinedName;
}

@ -0,0 +1,9 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
import { DefinedName } from "./DefinedName";
import { Range } from "../Range";
export interface DefinedNameCollection {
readonly items: DefinedName[];
readonly count: number;
add(name: string, ref: string | Range, comment?: string): DefinedName;
getName(name: string): DefinedName;
}

@ -0,0 +1,27 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/// <reference path="../../../../src/xlsx.d.ts" />
import { DefinedNameCollection } from "./DefinedNameCollection";
import { DefinedName } from "./DefinedName";
export declare class WorkbookDefinedNameCollection implements DefinedNameCollection {
private readonly _wb;
constructor(wb: XLSX.WorkBook);
/**
* Get read-only array of global defined names
*/
readonly items: DefinedName[];
/**
* Get defined name object
*/
getName(name: string): DefinedName;
/**
* Number of global defined names
*/
readonly count: number;
/**
* Add or update defined name
* @param name String name
* @param ref Range object or string range/formula
* @param comment Optional comment
*/
add(name: string, ref: string, comment?: string): DefinedName;
}

@ -0,0 +1,6 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/// <reference path="../../../../src/xlsx.d.ts" />
export declare class WorksheetCollection {
private readonly _wb;
constructor(wb: XLSX.WorkBook);
}

2
packages/s/dist/typings/umd.d.ts vendored Normal file

@ -0,0 +1,2 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
export * from "./index";

4
packages/s/esm.mjs Normal file

@ -0,0 +1,4 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
export * from "./dist/mjs/index.mjs";

4
packages/s/index.js Normal file

@ -0,0 +1,4 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
module.exports = require('./dist/cjs/');

2
packages/s/misc/.gitignore vendored Normal file

@ -0,0 +1,2 @@
S.js
parcel/

@ -0,0 +1,15 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
import assert from "assert";
import * as S from "../esm";
/* song and dance for node 12 esm */
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
const XLSX = require("../../../");
assert(S != null);
S.set_XLSX(XLSX);
assert(S.get_XLSX() == XLSX);
assert(S.get_XLSX().version);

8
packages/s/misc/make_mjs.sh Executable file

@ -0,0 +1,8 @@
#!/bin/bash
rm -rf dist/mjs/
cp -r dist/esm dist/mjs
find dist/mjs -name '*.js' | while read x; do
<"$x" awk '/(im|ex)port / { gsub(/";/, ".mjs\";"); } 1' > "${x%.js}.mjs"
rm -f "$x"
done

@ -0,0 +1,8 @@
import * as S from "../esm";
const XLSX = require("./xlsx.mini.min.js");
function assert(x) { if(!x) throw "assert failed"; }
assert(S != null);
S.set_XLSX(XLSX);
assert(S.get_XLSX() == XLSX);
assert(S.get_XLSX().version);

@ -0,0 +1,15 @@
const puppeteer = require("puppeteer");
const path = require("path");
const target = "http://localhost:7262/misc/module.html";
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.waitFor(1000);
console.log("page");
page.on('console', msg => console.log('PAGE LOG:', msg.text()));
page.on('error', (err) => { console.error(err); process.exit(1); });
page.on('pageerror', (err) => { console.error(err); process.exit(2); });
await page.goto(target);
await browser.close();
})();

@ -0,0 +1,14 @@
const puppeteer = require("puppeteer");
const path = require("path");
const target = `file://${path.resolve(`${__dirname}/parcel/parcelout.html`)}`;
console.log(target);
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
page.on('console', msg => console.log('PAGE LOG:', msg.text()));
page.on('error', (err) => { console.error(err); process.exit(1); });
page.on('pageerror', (err) => { console.error(err); process.exit(2); });
await page.goto(target);
await browser.close();
})();

@ -0,0 +1,14 @@
const puppeteer = require("puppeteer");
const path = require("path");
const target = `file://${path.resolve(`${__dirname}/standalone.html`)}`;
console.log(target);
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
page.on('console', msg => console.log('PAGE LOG:', msg.text()));
page.on('error', (err) => { console.error(err); process.exit(1); });
page.on('pageerror', (err) => { console.error(err); process.exit(2); });
await page.goto(target);
await browser.close();
})();

@ -0,0 +1,11 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
var assert = require("assert");
var XLSX = require("../../../");
var S = require("../");
assert(S != null);
S.set_XLSX(XLSX);
assert(S.get_XLSX() == XLSX);
assert(S.get_XLSX().version);

@ -0,0 +1,2 @@
var S = require("../");
module.exports = S;

@ -0,0 +1,10 @@
module.exports = {
output: {
libraryTarget: "var",
library: "S"
},
node: {
process: false,
browser: false
}
}

1
packages/s/misc/xlsx.mini.min.js vendored Symbolic link

@ -0,0 +1 @@
../../../dist/xlsx.mini.min.js

53
packages/s/package.json Normal file

@ -0,0 +1,53 @@
{
"name": "s",
"version": "1.0.0",
"author": "sheetjs",
"description": "SheetJS Spreadsheet Helper Library",
"keywords": [
"excel",
"office",
"spreadsheet"
],
"bin": {},
"browser": {
"buffer": false,
"crypto": false,
"stream": false,
"process": false,
"fs": false
},
"main": "./index.js",
"module": "./dist/esm/index.js",
"types": "./dist/typings/index.d.ts",
"dependencies": {},
"devDependencies": {
"@types/mocha": "^5.2.7",
"mocha": "^6.2.0",
"ts-node": "^8.3.0"
},
"repository": {
"type": "git",
"url": "git://github.com/SheetJS/js-xlsx.git"
},
"scripts": {},
"config": {
"blanket": {
"pattern": "xlsx.js"
}
},
"alex": {
"allow": [
"crash",
"wtf",
"holes"
]
},
"homepage": "http://sheetjs.com/opensource",
"bugs": {
"url": "https://github.com/SheetJS/js-xlsx/issues"
},
"license": "Apache-2.0",
"engines": {
"node": ">=0.8"
}
}

5
packages/s/src/index.ts Normal file

@ -0,0 +1,5 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
export { Workbook } from "./s/Workbook";
export { get_XLSX, set_XLSX } from "./s/XLSXWrapper";

@ -0,0 +1,5 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
export class Range {
};

@ -0,0 +1,28 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
/// <reference path="../xlsx.d.ts"/>
import { get_XLSX } from "./XLSXWrapper";
import { WorksheetCollection } from "./worksheet/WorksheetCollection";
import { DefinedNameCollection } from "./names/DefinedNameCollection";
import { WorkbookDefinedNameCollection } from "./names/WorkbookDefinedNameCollection";
export class Workbook {
private readonly _wb: XLSX.WorkBook;
private readonly _ws: WorksheetCollection;
private readonly _names: WorkbookDefinedNameCollection;
constructor(wb?: XLSX.WorkBook) {
this._wb = wb || get_XLSX().utils.book_new();
this._ws = new WorksheetCollection(this._wb);
this._names = new WorkbookDefinedNameCollection(this._wb);
};
get wb(): XLSX.WorkBook { return this._wb; };
get names(): DefinedNameCollection { return this._names; }
get worksheets(): WorksheetCollection { return this._ws; };
};

@ -0,0 +1,10 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
/// <reference path="../xlsx.d.ts"/>
let _XLSX: typeof XLSX;
if(typeof XLSX !== "undefined") _XLSX = XLSX;
export function get_XLSX() { return _XLSX; };
export function set_XLSX(xlsx: typeof XLSX) { _XLSX = xlsx; };

@ -0,0 +1,15 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
/// <reference path="../../xlsx.d.ts"/>
export class DefinedName {
readonly _name: XLSX.DefinedName;
constructor(name: XLSX.DefinedName) {
this._name = name;
};
get raw(): XLSX.DefinedName { return this._name; };
};

@ -0,0 +1,12 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
import { DefinedName } from "./DefinedName";
import { Range } from "../Range";
export interface DefinedNameCollection {
readonly items: DefinedName[];
readonly count: number;
add(name: string, ref: string | Range, comment?: string): DefinedName;
getName(name: string): DefinedName;
};

@ -0,0 +1,67 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
/// <reference path="../../xlsx.d.ts"/>
import { DefinedNameCollection } from "./DefinedNameCollection";
import { DefinedName } from "./DefinedName";
//import { Range } from "../Range";
export class WorkbookDefinedNameCollection implements DefinedNameCollection {
private readonly _wb: XLSX.WorkBook;
constructor(wb: XLSX.WorkBook) {
this._wb = wb;
};
/**
* Get read-only array of global defined names
*/
get items(): DefinedName[] {
if(!this._wb.Workbook) return [];
if(!this._wb.Workbook.Names) return [];
return this._wb.Workbook.Names.filter((name) => {name.Sheet == null}).map((name) => new DefinedName(name));
};
/**
* Get defined name object
*/
getName(name: string): DefinedName {
if(this._wb.Workbook && this._wb.Workbook.Names) {
const names = this._wb.Workbook.Names;
for(let i = 0; i < names.length; ++i) {
if(names[i].Name.toLowerCase() != name.toLowerCase()) continue;
if(names[i].Sheet != null) continue;
return new DefinedName(names[i]);
}
}
throw new Error(`Cannot find defined name |${name}|`);
}
/**
* Number of global defined names
*/
get count(): number {
if(!this._wb.Workbook) return 0;
if(!this._wb.Workbook.Names) return 0;
return this._wb.Workbook.Names.filter((name) => {typeof name.Sheet == "undefined"}).length;
}
/**
* Add or update defined name
* @param name String name
* @param ref Range object or string range/formula
* @param comment Optional comment
*/
add(name: string, ref: string /*TODO: | Range */, comment?: string): DefinedName {
try {
return this.getName(name);
} catch(e) {
const nm = { Name: name, Ref: ref.toString(), Comment: comment || "" };
if(!this._wb.Workbook) this._wb.Workbook = {};
if(!this._wb.Workbook.Names) this._wb.Workbook.Names = [];
this._wb.Workbook.Names.push(nm);
return new DefinedName(nm);
}
}
};

@ -0,0 +1,5 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
export class Worksheet {
}

@ -0,0 +1,12 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
/// <reference path="../../xlsx.d.ts"/>
export class WorksheetCollection {
private readonly _wb: XLSX.WorkBook;
constructor(wb: XLSX.WorkBook) {
this._wb = wb;
};
};

4
packages/s/src/umd.ts Normal file

@ -0,0 +1,4 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
export * from "./index";

804
packages/s/src/xlsx.d.ts vendored Normal file

@ -0,0 +1,804 @@
/* index.d.ts (C) 2015-present SheetJS and contributors */
// TypeScript Version: 2.2
declare namespace XLSX {
/** Version string */
export const version: string;
/** NODE ONLY! Attempts to read filename and parse */
export function readFile(filename: string, opts?: ParsingOptions): WorkBook;
/** Attempts to parse data */
export function read(data: any, opts?: ParsingOptions): WorkBook;
/** Attempts to write or download workbook data to file */
export function writeFile(data: WorkBook, filename: string, opts?: WritingOptions): any;
/** Attempts to write the workbook data */
export function write(data: WorkBook, opts?: WritingOptions): any;
/** Utility Functions */
export const utils: XLSX$Utils;
/** Stream Utility Functions */
export const stream: StreamUtils;
/** Number Format (either a string or an index to the format table) */
export type NumberFormat = string | number;
/** Basic File Properties */
export interface Properties {
/** Summary tab "Title" */
Title?: string;
/** Summary tab "Subject" */
Subject?: string;
/** Summary tab "Author" */
Author?: string;
/** Summary tab "Manager" */
Manager?: string;
/** Summary tab "Company" */
Company?: string;
/** Summary tab "Category" */
Category?: string;
/** Summary tab "Keywords" */
Keywords?: string;
/** Summary tab "Comments" */
Comments?: string;
/** Statistics tab "Last saved by" */
LastAuthor?: string;
/** Statistics tab "Created" */
CreatedDate?: Date;
}
/** Other supported properties */
export interface FullProperties extends Properties {
ModifiedDate?: Date;
Application?: string;
AppVersion?: string;
DocSecurity?: string;
HyperlinksChanged?: boolean;
SharedDoc?: boolean;
LinksUpToDate?: boolean;
ScaleCrop?: boolean;
Worksheets?: number;
SheetNames?: string[];
ContentStatus?: string;
LastPrinted?: string;
Revision?: string | number;
Version?: string;
Identifier?: string;
Language?: string;
}
export interface CommonOptions {
/**
* If true, throw errors when features are not understood
* @default false
*/
WTF?: boolean;
/**
* When reading a file with VBA macros, expose CFB blob to `vbaraw` field
* When writing BIFF8/XLSB/XLSM, reseat `vbaraw` and export to file
* @default false
*/
bookVBA?: boolean;
/**
* When reading a file, store dates as type d (default is n)
* When writing XLSX/XLSM file, use native date (default uses date codes)
* @default false
*/
cellDates?: boolean;
/**
* When reading a file, save style/theme info to the .s field
* When writing a file, export style/theme info
* @default false
*/
cellStyles?: boolean;
}
export interface DateNFOption {
/** Use specified date format */
dateNF?: NumberFormat;
}
/** Options for read and readFile */
export interface ParsingOptions extends CommonOptions {
/** Input data encoding */
type?: 'base64' | 'binary' | 'buffer' | 'file' | 'array' | 'string';
/** Default codepage */
codepage?: number;
/**
* Save formulae to the .f field
* @default true
*/
cellFormula?: boolean;
/**
* Parse rich text and save HTML to the .h field
* @default true
*/
cellHTML?: boolean;
/**
* Save number format string to the .z field
* @default false
*/
cellNF?: boolean;
/**
* Generate formatted text to the .w field
* @default true
*/
cellText?: boolean;
/** Override default date format (code 14) */
dateNF?: string;
/**
* Create cell objects for stub cells
* @default false
*/
sheetStubs?: boolean;
/**
* If >0, read the first sheetRows rows
* @default 0
*/
sheetRows?: number;
/**
* If true, parse calculation chains
* @default false
*/
bookDeps?: boolean;
/**
* If true, add raw files to book object
* @default false
*/
bookFiles?: boolean;
/**
* If true, only parse enough to get book metadata
* @default false
*/
bookProps?: boolean;
/**
* If true, only parse enough to get the sheet names
* @default false
*/
bookSheets?: boolean;
/**
* If defined and file is encrypted, use password
* @default ''
*/
password?: string;
/* If true, plaintext parsing will not parse values */
raw?: boolean;
dense?: boolean;
}
/** Options for write and writeFile */
export interface WritingOptions extends CommonOptions {
/** Output data encoding */
type?: 'base64' | 'binary' | 'buffer' | 'file' | 'array' | 'string';
/**
* Generate Shared String Table
* @default false
*/
bookSST?: boolean;
/**
* File format of generated workbook
* @default 'xlsx'
*/
bookType?: BookType;
/**
* Name of Worksheet (for single-sheet formats)
* @default ''
*/
sheet?: string;
/**
* Use ZIP compression for ZIP-based formats
* @default false
*/
compression?: boolean;
/**
* Suppress "number stored as text" errors in generated files
* @default true
*/
ignoreEC?: boolean;
/** Override workbook properties on save */
Props?: Properties;
}
/** Workbook Object */
export interface WorkBook {
/**
* A dictionary of the worksheets in the workbook.
* Use SheetNames to reference these.
*/
Sheets: { [sheet: string]: WorkSheet };
/** Ordered list of the sheet names in the workbook */
SheetNames: string[];
/** Standard workbook Properties */
Props?: FullProperties;
/** Custom workbook Properties */
Custprops?: object;
Workbook?: WBProps;
vbaraw?: any;
}
export interface SheetProps {
/** Sheet Visibility (0=Visible 1=Hidden 2=VeryHidden) */
Hidden?: 0 | 1 | 2;
/** Name of Document Module in associated VBA Project */
CodeName?: string;
}
/** Defined Name Object */
export interface DefinedName {
/** Name */
Name: string;
/** Reference */
Ref: string;
/** Scope (undefined for workbook scope) */
Sheet?: number;
/** Name comment */
Comment?: string;
}
/** Workbook-Level Attributes */
export interface WBProps {
/** Sheet Properties */
Sheets?: SheetProps[];
/** Defined Names */
Names?: DefinedName[];
/** Workbook Views */
Views?: WBView[];
/** Other Workbook Properties */
WBProps?: WorkbookProperties;
}
/** Workbook View */
export interface WBView {
/** Right-to-left mode */
RTL?: boolean;
}
/** Other Workbook Properties */
export interface WorkbookProperties {
/** Worksheet Epoch (1904 if true, 1900 if false) */
date1904?: boolean;
/** Warn or strip personally identifying info on save */
filterPrivacy?: boolean;
/** Name of Document Module in associated VBA Project */
CodeName?: string;
}
/** Column Properties Object */
export interface ColInfo {
/* --- visibility --- */
/** if true, the column is hidden */
hidden?: boolean;
/* --- column width --- */
/** width in Excel's "Max Digit Width", width*256 is integral */
width?: number;
/** width in screen pixels */
wpx?: number;
/** width in "characters" */
wch?: number;
/** Excel's "Max Digit Width" unit, always integral */
MDW?: number;
}
/** Row Properties Object */
export interface RowInfo {
/* --- visibility --- */
/** if true, the column is hidden */
hidden?: boolean;
/* --- row height --- */
/** height in screen pixels */
hpx?: number;
/** height in points */
hpt?: number;
/** outline / group level */
level?: number;
}
/**
* Write sheet protection properties.
*/
export interface ProtectInfo {
/**
* The password for formats that support password-protected sheets
* (XLSX/XLSB/XLS). The writer uses the XOR obfuscation method.
*/
password?: string;
/**
* Select locked cells
* @default: true
*/
selectLockedCells?: boolean;
/**
* Select unlocked cells
* @default: true
*/
selectUnlockedCells?: boolean;
/**
* Format cells
* @default: false
*/
formatCells?: boolean;
/**
* Format columns
* @default: false
*/
formatColumns?: boolean;
/**
* Format rows
* @default: false
*/
formatRows?: boolean;
/**
* Insert columns
* @default: false
*/
insertColumns?: boolean;
/**
* Insert rows
* @default: false
*/
insertRows?: boolean;
/**
* Insert hyperlinks
* @default: false
*/
insertHyperlinks?: boolean;
/**
* Delete columns
* @default: false
*/
deleteColumns?: boolean;
/**
* Delete rows
* @default: false
*/
deleteRows?: boolean;
/**
* Sort
* @default: false
*/
sort?: boolean;
/**
* Filter
* @default: false
*/
autoFilter?: boolean;
/**
* Use PivotTable reports
* @default: false
*/
pivotTables?: boolean;
/**
* Edit objects
* @default: true
*/
objects?: boolean;
/**
* Edit scenarios
* @default: true
*/
scenarios?: boolean;
}
/** Page Margins -- see Excel Page Setup .. Margins diagram for explanation */
export interface MarginInfo {
/** Left side margin (inches) */
left?: number;
/** Right side margin (inches) */
right?: number;
/** Top side margin (inches) */
top?: number;
/** Bottom side margin (inches) */
bottom?: number;
/** Header top margin (inches) */
header?: number;
/** Footer bottom height (inches) */
footer?: number;
}
export type SheetType = 'sheet' | 'chart';
export type SheetKeys = string | MarginInfo | SheetType;
/** General object representing a Sheet (worksheet or chartsheet) */
export interface Sheet {
/**
* Indexing with a cell address string maps to a cell object
* Special keys start with '!'
*/
[cell: string]: CellObject | SheetKeys | any;
/** Sheet type */
'!type'?: SheetType;
/** Sheet Range */
'!ref'?: string;
/** Page Margins */
'!margins'?: MarginInfo;
}
/** AutoFilter properties */
export interface AutoFilterInfo {
/** Range of the AutoFilter table */
ref: string;
}
export type WSKeys = SheetKeys | ColInfo[] | RowInfo[] | Range[] | ProtectInfo | AutoFilterInfo;
/** Worksheet Object */
export interface WorkSheet extends Sheet {
/**
* Indexing with a cell address string maps to a cell object
* Special keys start with '!'
*/
[cell: string]: CellObject | WSKeys | any;
/** Column Info */
'!cols'?: ColInfo[];
/** Row Info */
'!rows'?: RowInfo[];
/** Merge Ranges */
'!merges'?: Range[];
/** Worksheet Protection info */
'!protect'?: ProtectInfo;
/** AutoFilter info */
'!autofilter'?: AutoFilterInfo;
}
/**
* The Excel data type for a cell.
* b Boolean, n Number, e error, s String, d Date, z Stub
*/
export type ExcelDataType = 'b' | 'n' | 'e' | 's' | 'd' | 'z';
/**
* Type of generated workbook
* @default 'xlsx'
*/
export type BookType = 'xlsx' | 'xlsm' | 'xlsb' | 'xls' | 'xla' | 'biff8' | 'biff5' | 'biff2' | 'xlml' | 'ods' | 'fods' | 'csv' | 'txt' | 'sylk' | 'html' | 'dif' | 'rtf' | 'prn' | 'eth';
/** Comment element */
export interface Comment {
/** Author of the comment block */
a?: string;
/** Plaintext of the comment */
t: string;
}
/** Link object */
export interface Hyperlink {
/** Target of the link (HREF) */
Target: string;
/** Plaintext tooltip to display when mouse is over cell */
Tooltip?: string;
}
/** Worksheet Cell Object */
export interface CellObject {
/** The raw value of the cell. Can be omitted if a formula is specified */
v?: string | number | boolean | Date;
/** Formatted text (if applicable) */
w?: string;
/**
* The Excel Data Type of the cell.
* b Boolean, n Number, e Error, s String, d Date, z Empty
*/
t: ExcelDataType;
/** Cell formula (if applicable) */
f?: string;
/** Range of enclosing array if formula is array formula (if applicable) */
F?: string;
/** Rich text encoding (if applicable) */
r?: any;
/** HTML rendering of the rich text (if applicable) */
h?: string;
/** Comments associated with the cell */
c?: Comment[];
/** Number format string associated with the cell (if requested) */
z?: NumberFormat;
/** Cell hyperlink object (.Target holds link, .tooltip is tooltip) */
l?: Hyperlink;
/** The style/theme of the cell (if applicable) */
s?: any;
}
/** Simple Cell Address */
export interface CellAddress {
/** Column number */
c: number;
/** Row number */
r: number;
}
/**
* Range object (representing ranges like "A1:B2")
*/
export interface Range {
/** Starting cell */
s: CellAddress;
/** Ending cell */
e: CellAddress;
}
export interface Sheet2CSVOpts extends DateNFOption {
/** Field Separator ("delimiter") */
FS?: string;
/** Record Separator ("row separator") */
RS?: string;
/** Remove trailing field separators in each record */
strip?: boolean;
/** Include blank lines in the CSV output */
blankrows?: boolean;
/** Skip hidden rows and columns in the CSV output */
skipHidden?: boolean;
}
export interface OriginOption {
/** Top-Left cell for operation (CellAddress or A1 string or row) */
origin?: number | string | CellAddress;
}
export interface Sheet2HTMLOpts {
/** TABLE element id attribute */
id?: string;
/** Add contenteditable to every cell */
editable?: boolean;
/** Header HTML */
header?: string;
/** Footer HTML */
footer?: string;
}
export interface Sheet2JSONOpts extends DateNFOption {
/** Output format */
header?: "A"|number|string[];
/** Override worksheet range */
range?: any;
/** Include or omit blank lines in the output */
blankrows?: boolean;
/** Default value for null/undefined values */
defval?: any;
/** if true, return raw data; if false, return formatted text */
raw?: boolean;
}
export interface AOA2SheetOpts extends CommonOptions, DateNFOption {
/**
* Create cell objects for stub cells
* @default false
*/
sheetStubs?: boolean;
}
export interface SheetAOAOpts extends AOA2SheetOpts, OriginOption {}
export interface JSON2SheetOpts extends CommonOptions, DateNFOption {
/** Use specified column order */
header?: string[];
/** Skip header row in generated sheet */
skipHeader?: boolean;
}
export interface SheetJSONOpts extends JSON2SheetOpts, OriginOption {}
export interface Table2SheetOpts extends CommonOptions, DateNFOption {
/* If true, plaintext parsing will not parse values */
raw?: boolean;
/**
* If >0, read the first sheetRows rows
* @default 0
*/
sheetRows?: number;
/** If true, hidden rows and cells will not be parsed */
display?: boolean;
}
/** General utilities */
export interface XLSX$Utils {
/* --- Import Functions --- */
/** Converts an array of arrays of JS data to a worksheet. */
aoa_to_sheet<T>(data: T[][], opts?: AOA2SheetOpts): WorkSheet;
aoa_to_sheet(data: any[][], opts?: AOA2SheetOpts): WorkSheet;
/** Converts an array of JS objects to a worksheet. */
json_to_sheet<T>(data: T[], opts?: JSON2SheetOpts): WorkSheet;
json_to_sheet(data: any[], opts?: JSON2SheetOpts): WorkSheet;
/** BROWSER ONLY! Converts a TABLE DOM element to a worksheet. */
table_to_sheet(data: any, opts?: Table2SheetOpts): WorkSheet;
table_to_book(data: any, opts?: Table2SheetOpts): WorkBook;
/* --- Export Functions --- */
/** Converts a worksheet object to an array of JSON objects */
sheet_to_json<T>(worksheet: WorkSheet, opts?: Sheet2JSONOpts): T[];
sheet_to_json(worksheet: WorkSheet, opts?: Sheet2JSONOpts): any[][];
sheet_to_json(worksheet: WorkSheet, opts?: Sheet2JSONOpts): any[];
/** 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;
/** Generates a list of the formulae (with value fallbacks) */
sheet_to_formulae(worksheet: WorkSheet): string[];
/** Generates DIF */
sheet_to_dif(worksheet: WorkSheet, options?: Sheet2HTMLOpts): string;
/** Generates SYLK (Symbolic Link) */
sheet_to_slk(worksheet: WorkSheet, options?: Sheet2HTMLOpts): string;
/** Generates ETH */
sheet_to_eth(worksheet: WorkSheet, options?: Sheet2HTMLOpts): string;
/* --- Cell Address Utilities --- */
/** Converts 0-indexed cell address to A1 form */
encode_cell(cell: CellAddress): string;
/** Converts 0-indexed row to A1 form */
encode_row(row: number): string;
/** Converts 0-indexed column to A1 form */
encode_col(col: number): string;
/** Converts 0-indexed range to A1 form */
encode_range(s: CellAddress, e: CellAddress): string;
encode_range(r: Range): string;
/** Converts A1 cell address to 0-indexed form */
decode_cell(address: string): CellAddress;
/** Converts A1 row to 0-indexed form */
decode_row(row: string): number;
/** Converts A1 column to 0-indexed form */
decode_col(col: string): number;
/** Converts A1 range to 0-indexed form */
decode_range(range: string): Range;
/** Format cell */
format_cell(cell: CellObject, v?: any, opts?: any): string;
/* --- General Utilities --- */
/** Creates a new workbook */
book_new(): WorkBook;
/** Append a worksheet to a workbook */
book_append_sheet(workbook: WorkBook, worksheet: WorkSheet, name?: string): void;
/** Set sheet visibility (visible/hidden/very hidden) */
book_set_sheet_visibility(workbook: WorkBook, sheet: number|string, visibility: number): void;
/** Set number format for a cell */
cell_set_number_format(cell: CellObject, fmt: string|number): CellObject;
/** Set hyperlink for a cell */
cell_set_hyperlink(cell: CellObject, target: string, tooltip?: string): CellObject;
/** Set internal link for a cell */
cell_set_internal_link(cell: CellObject, target: string, tooltip?: string): CellObject;
/** Add comment to a cell */
cell_add_comment(cell: CellObject, text: string, author?: string): void;
/** Assign an Array Formula to a range */
sheet_set_array_formula(ws: WorkSheet, range: Range|string, formula: string): WorkSheet;
/** Add an array of arrays of JS data to a worksheet */
sheet_add_aoa<T>(ws: WorkSheet, data: T[][], opts?: SheetAOAOpts): WorkSheet;
sheet_add_aoa(ws: WorkSheet, data: any[][], opts?: SheetAOAOpts): WorkSheet;
/** Add an array of JS objects to a worksheet */
sheet_add_json(ws: WorkSheet, data: any[], opts?: SheetJSONOpts): WorkSheet;
sheet_add_json<T>(ws: WorkSheet, data: T[], opts?: SheetJSONOpts): WorkSheet;
consts: XLSX$Consts;
}
export interface XLSX$Consts {
/* --- Sheet Visibility --- */
/** Visibility: Visible */
SHEET_VISIBLE: 0;
/** Visibility: Hidden */
SHEET_HIDDEN: 1;
/** Visibility: Very Hidden */
SHEET_VERYHIDDEN: 2;
}
/** NODE ONLY! these return Readable Streams */
export interface StreamUtils {
/** CSV output stream, generate one line at a time */
to_csv(sheet: WorkSheet, opts?: Sheet2CSVOpts): any;
/** HTML output stream, generate one line at a time */
to_html(sheet: WorkSheet, opts?: Sheet2HTMLOpts): any;
/** JSON object stream, generate one row at a time */
to_json(sheet: WorkSheet, opts?: Sheet2JSONOpts): any;
}
}

23
packages/s/test.ts Normal file

@ -0,0 +1,23 @@
/*! s.js (C) 2019-present SheetJS -- https://sheetjs.com */
/* vim: set ts=2: */
/// <reference path="src/xlsx.d.ts"/>
import { Workbook, set_XLSX, get_XLSX } from "./";
import * as assert from 'assert';
const XLSXLib: typeof XLSX = require("../../");
set_XLSX(XLSXLib);
import 'mocha';
describe('Defined Names', () => {
let wb = new Workbook();
it('should add names to blank workbook', () => {
let cnt = wb.names.count;
assert.equal(cnt, 0);
assert.throws(() => { const newname = wb.names.getName("wtf"); });
wb.names.add("wtf", "Sheet1!A1:A3", "dafuq");
assert.doesNotThrow(() => { const newname = wb.names.getName("wtf"); });
});
});

@ -0,0 +1,10 @@
{
"compilerOptions": {
"target": "es5",
"moduleResolution": "node",
"outDir": "./.out",
"lib": [ "es5" ],
"sourceMap": true,
"noImplicitReturns": true
}
}

10
packages/s/tsconfig.json Normal file

@ -0,0 +1,10 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"s": [ "./src/index" ]
}
},
"exclude": [ "./dist" ]
}

@ -0,0 +1,13 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmit": true
},
"exclude": [
"dist"
],
"formatCodeOptions": {
"indentSize": 2,
"tabSize": 2
}
}

@ -0,0 +1,16 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"noEmit": false,
"baseUrl": "../src",
"sourceRoot": "../src",
"paths": {
"s": [ "./" ],
"s/*": [ "./*" ]
}
},
"files": [
"../src/index.ts",
"../src/umd.ts"
]
}

@ -0,0 +1,8 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"outDir": "../dist/cjs"
}
}

Some files were not shown because too many files have changed in this diff Show More