Dia antes primera install

This commit is contained in:
2025-12-08 15:20:28 -06:00
commit 1416478c9c
4130 changed files with 886376 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
name: Run tests
on:
push:
pull_request:
permissions:
contents: read
jobs:
build:
permissions:
checks: write # for coverallsapp/github-action to create new checks
contents: read # for actions/checkout to fetch code
runs-on: ubuntu-latest
strategy:
matrix:
include:
- node-red-version: 3
node-version: 20
- node-red-version: 3
node-version: 18
- node-red-version: 3
node-version: 16
- node-red-version: 3
node-version: 14
- node-red-version: 2
node-version: 12
- node-red-version: 1
node-version: 12
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Install Dependencies
run: |
npm install
npm install node-red@${{ matrix.node-red-version}}
- name: Run tests
run: npm test

201
node_modules/node-red-contrib-spreadsheet-in/LICENSE generated vendored Normal file
View 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 {yyyy} {name of copyright owner}
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.

17
node_modules/node-red-contrib-spreadsheet-in/README.md generated vendored Normal file
View File

@@ -0,0 +1,17 @@
# node-red-contrib-spreadsheet-in
This package provides Node-RED nodes to read data from spreadsheet (Excel, ODS, etc.) file.
[![Run tests](https://github.com/sakai-to/node-red-contrib-spreadsheet-in/actions/workflows/tests.yml/badge.svg)](https://github.com/sakai-to/node-red-contrib-spreadsheet-in/actions/workflows/tests.yml)
## Usage
See the following screenshot:
![example flow](https://raw.githubusercontent.com/sakai-to/node-red-contrib-spreadsheet-in/master/examples/example.png "Example flow")
You can also import the example flow from `examples/example.json` to your Node-RED.
## ToDo
- Add useful properties for nodes

37
node_modules/node-red-contrib-spreadsheet-in/book.html generated vendored Normal file
View File

@@ -0,0 +1,37 @@
<script type="text/javascript">
RED.nodes.registerType('book',{
category: 'Spreadsheet',
color: "#DEBD5C",
defaults: {
name: {value:""},
raw: {value:false}
},
inputs:1,
outputs:1,
icon: "font-awesome/fa-file-excel-o",
label: function() {
return this.name||"book";
},
labelStyle: function() {
return this.name?"node_label_italic":"";
},
inputLabels: function() {
return this._("book.label.binaryBuffer");
},
outputLabels: function () {
return this._("book.label.workbookObject");
}
});
</script>
<script type="text/x-red" data-template-name="book">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
</div>
<div class="form-row">
<label><i class="fa fa-sign-out"></i> <span data-i18n="book.label.parse"></span></label>
<input type="checkbox" id="node-input-raw" style="width:auto">
<label for="node-input-raw" style="width:auto" data-i18n="book.label.raw"></label>
</div>
</script>

22
node_modules/node-red-contrib-spreadsheet-in/book.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
module.exports = function(RED) {
const XLSX = require('xlsx');
function BookNode(config) {
RED.nodes.createNode(this,config);
var node = this;
node.on('input', function(msg) {
var option = {
type: typeof msg.payload === "string" ? "string" : "buffer",
raw: config.raw,
// dateNF: "yyyy-mm-dd",
password: undefined,
cellNF: true,
cellStyles: true,
WTF: false,
};
msg.payload = XLSX.read(msg.payload, option);
node.send(msg);
});
}
RED.nodes.registerType("book",BookNode);
}

53
node_modules/node-red-contrib-spreadsheet-in/cell.html generated vendored Normal file
View File

@@ -0,0 +1,53 @@
<script type="text/javascript">
RED.nodes.registerType('cell',{
category: 'Spreadsheet',
color: "#DEBD5C",
defaults: {
name: {value:""},
address: {value:""},
dataType: {value:"w"}
},
inputs:1,
outputs:1,
icon: "font-awesome/fa-square-o",
label: function() {
return this.name||"cell";
},
labelStyle: function() {
return this.name?"node_label_italic":"";
},
inputLabels: function() {
return this._("cell.label.sheetObject");
},
outputLabels: function () {
return this._("cell.label.cellValue");
}
});
</script>
<script type="text/x-red" data-template-name="cell">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
</div>
<div class="form-row">
<label for="node-input-address"><i class="fa fa-crosshairs"></i> <span data-i18n="cell.label.address"></span></label>
<input type="text" id="node-input-address" data-i18n="[placeholder]cell.placeholder.address">
</div>
<div class="form-row">
<label for="node-input-dataType"><i class="fa fa-sign-out"></i> <span data-i18n="cell.label.dataType"></span></label>
<select id="node-input-dataType" style="width:70%">
<option value="v" data-i18n="cell.dataType.v"></option>
<option value="w" data-i18n="cell.dataType.w"></option>
<option value="t" data-i18n="cell.dataType.t"></option>
<option value="f" data-i18n="cell.dataType.f"></option>
<option value="F" data-i18n="cell.dataType.F"></option>
<option value="h" data-i18n="cell.dataType.h"></option>
<option value="c" data-i18n="cell.dataType.c"></option>
<option value="z" data-i18n="cell.dataType.z"></option>
<option value="l" data-i18n="cell.dataType.l"></option>
<option value="s" data-i18n="cell.dataType.s"></option>
<option value="" data-i18n="cell.dataType.none"></option>
</select>
</div>
</script>

25
node_modules/node-red-contrib-spreadsheet-in/cell.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
module.exports = function(RED) {
const XLSX = require('xlsx');
function CellNode(config) {
RED.nodes.createNode(this,config);
var node = this;
node.on('input', function(msg) {
var address = config.address || msg.selectAddress;
delete msg.selectAddress;
if (!address) {
return node.error(RED._("cell.errors.no-address"));
} else if (!/[A-Z]+[1-9][0-9]*/.test(address)) {
return node.error(RED._("cell.errors.invalid-address") + ": " + address);
}
var cell = msg.payload && msg.payload[address];
msg.payload = cell && config.dataType
? cell[config.dataType]
: cell;
msg.selectedAddress = address;
node.send(msg);
});
}
RED.nodes.registerType("cell",CellNode);
}

View File

@@ -0,0 +1,148 @@
[
{
"id": "9d4b3531.391338",
"type": "inject",
"z": "82c72b22.7e2728",
"name": "",
"topic": "",
"payload": "",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"x": 100,
"y": 40,
"wires": [
[
"1ef482ff.54be1d"
]
]
},
{
"id": "1ef482ff.54be1d",
"type": "file in",
"z": "82c72b22.7e2728",
"name": "read a spreadsheet file as binary buffer",
"filename": "",
"format": "",
"chunk": false,
"sendError": false,
"x": 370,
"y": 40,
"wires": [
[
"58da0822.79c4a8"
]
]
},
{
"id": "58da0822.79c4a8",
"type": "book",
"z": "82c72b22.7e2728",
"name": "",
"x": 270,
"y": 100,
"wires": [
[
"8bd99783.125c38",
"ed8b8fb2.0d17c"
]
]
},
{
"id": "ed8b8fb2.0d17c",
"type": "sheet",
"z": "82c72b22.7e2728",
"name": "",
"sheetName": "Sheet1",
"x": 270,
"y": 160,
"wires": [
[
"f0303664.0d9938",
"9c0ed110.bc235",
"fe9e8ba9.f59db8"
]
]
},
{
"id": "f0303664.0d9938",
"type": "cell",
"z": "82c72b22.7e2728",
"name": "",
"address": "A1",
"dataType": "w",
"x": 430,
"y": 220,
"wires": [
[
"99f7011e.3ecda"
]
]
},
{
"id": "9c0ed110.bc235",
"type": "sheet-to-json",
"z": "82c72b22.7e2728",
"name": "",
"raw": "false",
"range": "A1:B2",
"header": "default",
"blankrows": false,
"x": 450,
"y": 280,
"wires": [
[
"4c28547e.6d566c"
]
]
},
{
"id": "8bd99783.125c38",
"type": "debug",
"z": "82c72b22.7e2728",
"name": "",
"active": true,
"console": "false",
"complete": "payload.SheetNames",
"x": 600,
"y": 100,
"wires": []
},
{
"id": "99f7011e.3ecda",
"type": "debug",
"z": "82c72b22.7e2728",
"name": "",
"active": true,
"console": "false",
"complete": "false",
"x": 650,
"y": 220,
"wires": []
},
{
"id": "4c28547e.6d566c",
"type": "debug",
"z": "82c72b22.7e2728",
"name": "",
"active": true,
"console": "false",
"complete": "false",
"x": 650,
"y": 280,
"wires": []
},
{
"id": "fe9e8ba9.f59db8",
"type": "debug",
"z": "82c72b22.7e2728",
"name": "",
"active": true,
"console": "false",
"complete": "false",
"x": 650,
"y": 160,
"wires": []
}
]

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

View File

@@ -0,0 +1,28 @@
<script type="text/x-red" data-help-name="book">
<p>Converts the contents of a spreadsheet file to a workbook object.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>payload
<span class="property-type">Buffer</span>
</dt>
<dd>a Buffer object of the contents of a spreadsheet file.</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">object</span></dt>
<dd>a workbook object decoded from the Buffer object.</dd>
</dl>
<h3>Details</h3>
<p>If you want to read a spreadsheet file using file-in node, you should set the Output type property of the file-in node should be set to binary buffer.
Otherwise, you will get an error in this node.</p>
<p>If Parse property is checked, this node suppresses to interpret values from CSV and other plain text.</p>
<h3>References</h3>
<ul>
<li><a href="https://sheetjs.gitbooks.io/docs/#sheetjs-js-xlsx" target="_blank">SheetJS js-xlsx</a> - full description of js-xlsx which this node is based on.</li>
<li><a href="https://github.com/sakai-to/node-red-contrib-spreadsheet-in" target="_blank">GitHub</a> - the nodes github repository.</li>
</ul>
</script>

View File

@@ -0,0 +1,10 @@
{
"book": {
"label": {
"binaryBuffer": "Binary buffer",
"workbookObject": "Workbook object",
"parse": "Parse",
"raw": "Plain text parsing will not parse values"
}
}
}

View File

@@ -0,0 +1,31 @@
<script type="text/x-red" data-help-name="cell">
<p>Picks a cell value from a sheet object.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>payload
<span class="property-type">object</span>
</dt>
<dd>a sheet object from a sheet node.</dd>
<dt class="optional">selectAddress <span class="property-type">string</span></dt>
<dd>If the Address property is not configured in the node, this optional property sets an A1-style cell address.</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">any</span></dt>
<dd>the cell value as selecting the Data type property.</dd>
<dt>selectedAddress <span class="property-type">string</span></dt>
<dd>The A1-style address of the cell which the value is picked from.</dd>
</dl>
<h3>Details</h3>
<p>The Address proprty or <code>msg.selectAddress</code> property should be set an A1-style cell address.</p>
<p>Regarding the details for the Data type property, please see the <a href="https://sheetjs.gitbooks.io/docs/#cell-object" target="_blank">description of js-xlsx</a>.</p>
<h3>References</h3>
<ul>
<li><a href="https://sheetjs.gitbooks.io/docs/#sheetjs-js-xlsx" target="_blank">SheetJS js-xlsx</a> - full description of js-xlsx which this node is based on.</li>
<li><a href="https://github.com/sakai-to/node-red-contrib-spreadsheet-in" target="_blank">GitHub</a> - the nodes github repository.</li>
</ul>
</script>

View File

@@ -0,0 +1,30 @@
{
"cell": {
"label": {
"address": "Cell address",
"dataType": "Data type",
"sheetObject": "Sheet object",
"cellValue": "Cell value"
},
"placeholder": {
"address": "A1"
},
"dataType": {
"v": "raw value",
"w": "formatted text",
"t": "cell type",
"f": "cell formula",
"F": "range of enclosing array",
"h": "HTML rendering of the rich text",
"c": "comments associated with the cell",
"z": "number format string",
"l": "cell hyperlink object",
"s": "the style/theme of the cell",
"none": "xlsx cell object"
},
"errors": {
"no-address": "Cell address not specified",
"invalid-address": "Invalid cell address"
}
}
}

View File

@@ -0,0 +1,34 @@
<script type="text/x-red" data-help-name="sheet-to-json">
<p>Converts a sheet object to an array of JSON objects.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>payload
<span class="property-type">object</span>
</dt>
<dd>a sheet object from a sheet node.</dd>
<dt class="optional">selectRange <span class="property-type">string</span></dt>
<dd>If the Range property is not configured in the node, this optional property sets an A-1 based range.</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">object</span></dt>
<dd>an array of objects which represents cell values in the sheet object.</dd>
<dt>selectedRange <span class="property-type">string</span></dt>
<dd>the A-1 based range.</dd>
</dl>
<h3>Details</h3>
<p>This node generates different types of JS objects. This node takes the following properties.</p>
<p>The Data type property controls cell values to use raw values or formatted strings.</p>
<p>The Range property or <code>msg.selectRange</code> property can be set an A-1 based range. If both are blank or undefined, the sheet range is used.</p>
<p>The Header property controls output format.</p>
<p>The Blank rows property controls to include blank lines in the output.</p>
<h3>References</h3>
<ul>
<li><a href="https://sheetjs.gitbooks.io/docs/#sheetjs-js-xlsx" target="_blank">SheetJS js-xlsx</a> - full description of js-xlsx which this node is based on.</li>
<li><a href="https://github.com/sakai-to/node-red-contrib-spreadsheet-in" target="_blank">GitHub</a> - the nodes github repository.</li>
</ul>
</script>

View File

@@ -0,0 +1,27 @@
{
"sheet-to-json": {
"label": {
"raw": "Data type",
"range": "Range",
"header": "Header",
"blankrows": "Blank rows",
"sheetObject": "Sheet object",
"cellValues": "Cell values"
},
"placeholder": {
"range": "A1:B2"
},
"raw": {
"false": "Formatted text",
"true": "Raw values"
},
"header": {
"1": "Generate an array of arrays",
"A": "Row object keys are literal column labels",
"default": "Read and disambiguate first row as keys"
},
"blankrows": {
"include": "Include blank lines in the output"
}
}
}

View File

@@ -0,0 +1,30 @@
<script type="text/x-red" data-help-name="sheet">
<p>Picks a sheet object from a workbook object.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>payload
<span class="property-type">object</span>
</dt>
<dd>a workbook object from a book node.</dd>
<dt class="optional">selectSheetName <span class="property-type">string</span></dt>
<dd>If the Sheet name property is not configured in the node, this optional property sets a sheet name.</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">object</span></dt>
<dd>an object of a sheet which is named by the Sheet name property.</dd>
<dt>selectedSheetName <span class="property-type">string</span></dt>
<dd>the selected sheet name.</dd>
</dl>
<h3>Details</h3>
<p>The Sheet name property or <code>msg.selectSheetName</code> property should be set the name of a sheet to pick from the workbook object.</p>
<h3>References</h3>
<ul>
<li><a href="https://sheetjs.gitbooks.io/docs/#sheetjs-js-xlsx" target="_blank">SheetJS js-xlsx</a> - full description of js-xlsx which this node is based on.</li>
<li><a href="https://github.com/sakai-to/node-red-contrib-spreadsheet-in" target="_blank">GitHub</a> - the nodes github repository.</li>
</ul>
</script>

View File

@@ -0,0 +1,12 @@
{
"sheet": {
"label": {
"sheetName": "Sheet name",
"workbookObject": "Workbook object",
"sheetObject": "Sheet object"
},
"placeholder": {
"sheetName": "Sheet1"
}
}
}

View File

@@ -0,0 +1,28 @@
<script type="text/x-red" data-help-name="book">
<p>スプレッドシートの内容をワークブックオブジェクトに変換します</p>
<h3>入力</h3>
<dl class="message-properties">
<dt>payload
<span class="property-type">Buffer</span>
</dt>
<dd>スプレッドシートファイルの内容のBufferオブジェクト</dd>
</dl>
<h3>出力</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">object</span></dt>
<dd>Bufferオブジェクトからデコードされたワークブックオブジェクト</dd>
</dl>
<h3>詳細</h3>
<p>file-inードを使用してスプレッドシートファイルを読み込みたい場合file-inードの出力形式プロパティにバイナリバッファを設定します
そうでない場合このノードでエラーが発生します</p>
<p>解析プロパティがチェックされている場合このードはCSVおよびその他のプレーンテキストからの値を解釈することを抑制します</p>
<h3>参照</h3>
<ul>
<li><a href="https://sheetjs.gitbooks.io/docs/#sheetjs-js-xlsx" target="_blank">SheetJS js-xlsx</a> - js-xlsx</li>
<li><a href="https://github.com/sakai-to/node-red-contrib-spreadsheet-in" target="_blank">GitHub</a> - GitHub</li>
</ul>
</script>

View File

@@ -0,0 +1,10 @@
{
"book": {
"label": {
"binaryBuffer": "バイナリバッファ",
"workbookObject": "ワークブックオブジェクト",
"parse": "解析",
"raw": "プレーンテキストの値を解析しない"
}
}
}

View File

@@ -0,0 +1,31 @@
<script type="text/x-red" data-help-name="cell">
<p>シートオブジェクトからセルの値を取り出します</p>
<h3>入力</h3>
<dl class="message-properties">
<dt>payload
<span class="property-type">object</span>
</dt>
<dd>sheetードからのシートオブジェクト</dd>
<dt class="optional">selectAddress <span class="property-type">string</span></dt>
<dd>セルのアドレスプロパティがこのノードで設定されていない場合このオプションプロパティはA1形式のセルのアドレスを設定します</dd>
</dl>
<h3>出力</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">any</span></dt>
<dd>データタイププロパティの選択に応じたセルの値</dd>
<dt>selectedAddress <span class="property-type">string</span></dt>
<dd>値を取り出したセルのA1形式のアドレス</dd>
</dl>
<h3>詳細</h3>
<p>セルのアドレスプロパティまたは<code>msg.selectAddress</code>A1</p>
<p>データタイププロパティの詳細については<a href="https://sheetjs.gitbooks.io/docs/#cell-object" target="_blank">js-xlsxの記述</a></p>
<h3>参照</h3>
<ul>
<li><a href="https://sheetjs.gitbooks.io/docs/#sheetjs-js-xlsx" target="_blank">SheetJS js-xlsx</a> - js-xlsx</li>
<li><a href="https://github.com/sakai-to/node-red-contrib-spreadsheet-in" target="_blank">GitHub</a> - GitHub</li>
</ul>
</script>

View File

@@ -0,0 +1,30 @@
{
"cell": {
"label": {
"address": "セルのアドレス",
"dataType": "データタイプ",
"sheetObject": "シートオブジェクト",
"cellValue": "セルの値"
},
"placeholder": {
"address": "A1"
},
"dataType": {
"v": "生データ",
"w": "表示されるテキスト",
"t": "セルのタイプ",
"f": "セルの数式",
"F": "配列数式の範囲",
"h": "HTML",
"c": "コメント",
"z": "セルの表示形式",
"l": "セルのハイパーリンクオブジェクト",
"s": "セルのスタイル/テーマ",
"none": "xlsxのセルオブジェクト"
},
"errors": {
"no-address": "セルのアドレスが指定されていません",
"invalid-address": "無効なセルのアドレスです"
}
}
}

View File

@@ -0,0 +1,34 @@
<script type="text/x-red" data-help-name="sheet-to-json">
<p>シートオブジェクトをJSONオブジェクトの配列に変換します</p>
<h3>入力</h3>
<dl class="message-properties">
<dt>payload
<span class="property-type">object</span>
</dt>
<dd>sheetードからのシートオブジェクト</dd>
<dt class="optional">selectRange <span class="property-type">string</span></dt>
<dd>範囲プロパティがこのノードで設定されていない場合このオプションプロパティはA1形式の範囲を設定します</dd>
</dl>
<h3>出力</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">object</span></dt>
<dd>シートオブジェクト内のセルの値を表すオブジェクトの配列</dd>
<dt>selectedRange <span class="property-type">string</span></dt>
<dd>A1形式の範囲</dd>
</dl>
<h3>詳細</h3>
<p>このードは異なる種類のJSオブジェクトを生成しますこのノードは次のプロパティを取ります</p>
<p>データタイププロパティはセルの値として生データを使うかまたは表示されるテキストを使うかを制御します</p>
<p>範囲プロパティまたは<code>msg.selectRange</code>A1undefined使</p>
<p>ヘッダープロパティは出力形式を制御します</p>
<p>空行プロパティは空行を出力に含めるかを制御します</p>
<h3>参照</h3>
<ul>
<li><a href="https://sheetjs.gitbooks.io/docs/#sheetjs-js-xlsx" target="_blank">SheetJS js-xlsx</a> - js-xlsx</li>
<li><a href="https://github.com/sakai-to/node-red-contrib-spreadsheet-in" target="_blank">GitHub</a> - GitHub</li>
</ul>
</script>

View File

@@ -0,0 +1,27 @@
{
"sheet-to-json": {
"label": {
"raw": "データタイプ",
"range": "範囲",
"header": "ヘッダー",
"blankrows": "空行",
"sheetObject": "シートオブジェクト",
"cellValues": "セルの値"
},
"placeholder": {
"range": "A1:B2"
},
"raw": {
"false": "表示されるテキスト",
"true": "生データ"
},
"header": {
"1": "配列の配列を生成",
"A": "行オブジェクトのキーは列ラベル文字",
"default": "曖昧さのない最初の行をキーとして読み込む"
},
"blankrows": {
"include": "空行を出力に含める"
}
}
}

View File

@@ -0,0 +1,30 @@
<script type="text/x-red" data-help-name="sheet">
<p>ワークブックオブジェクトからシートオブジェクトを取り出します</p>
<h3>入力</h3>
<dl class="message-properties">
<dt>payload
<span class="property-type">object</span>
</dt>
<dd>bookードからのワークブックオブジェクト</dd>
<dt class="optional">selectSheetName <span class="property-type">string</span></dt>
<dd>シート名プロパティがこのノードで設定されていない場合このオプションプロパティはシート名を設定します</dd>
</dl>
<h3>出力</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">object</span></dt>
<dd>シート名プロパティで指定されたシートオブジェクト</dd>
<dt>selectedSheetName <span class="property-type">string</span></dt>
<dd>選択されたシート名</dd>
</dl>
<h3>詳細</h3>
<p>シート名プロパティまたは<code>msg.selectSheetName</code></p>
<h3>参照</h3>
<ul>
<li><a href="https://sheetjs.gitbooks.io/docs/#sheetjs-js-xlsx" target="_blank">SheetJS js-xlsx</a> - js-xlsx</li>
<li><a href="https://github.com/sakai-to/node-red-contrib-spreadsheet-in" target="_blank">GitHub</a> - GitHub</li>
</ul>
</script>

View File

@@ -0,0 +1,12 @@
{
"sheet": {
"label": {
"sheetName": "シート名",
"workbookObject": "ワークブックオブジェクト",
"sheetObject": "シートオブジェクト"
},
"placeholder": {
"sheetName": "シート1"
}
}
}

View File

@@ -0,0 +1 @@
../xlsx/bin/xlsx.njs

View File

@@ -0,0 +1,328 @@
# CHANGELOG
This log is intended to keep track of backwards-incompatible changes, including
but not limited to API changes and file location changes. Minor behavioral
changes may not be included if they are not expected to break existing code.
## v0.19.3
* XLSX Ensure comment address is valid (h/t @slonser)
* Enforce Excel worksheet name restrictions
## v0.19.2
* XLSX proper decoding of hyperlinks (h/t @tw-yaxu)
* XLSX ignore unexpected attributes in rich text (h/t @colin4)
* `sheet_to_json` type fix (h/t @chsdwn)
## v0.19.1
* Fixed types issue in strict mode (h/t @younes-io)
* Numbers 12.2 parsing skip ActivityStream.iwa
## v0.19.0
* XLSX export hyperlinks compatible with google sheets (h/t Evan Bovie)
* NUMBERS export multiple sheets, full worksheet range
* formalized `dense` mode
## v0.18.12
* `package.json` added types in `exports` structure
* uncapped NUMBERS single-sheet single-table export
* DBF export records using supported codepages
## v0.18.11
* Base64 input ignore data URI wrapper
* Parse ZIP files that use ZIP64 extended information field
* More precise handling of time-only values
* Threaded Comment fallback text for older Excel
## v0.18.10
* `exports` field in package.json to satiate ViteJS and newer tooling
* JSC (Safari / Bun) perf, see <https://bugs.webkit.org/show_bug.cgi?id=243148>
* workbook `bookType` property to denote the origin format when parsed from file
* XLSX force export of stub cells with number formats when `sheetStubs` is set
## v0.18.9
* XLSX / ODS write defined names
* sync defined names to AutoFilter setting on export
* 1904 date system setting properly roundtripped
* ODS read/write number formats
## v0.18.8
* Plaintext parsing of dateless meridien time values (`1:23:45 PM`)
* Legacy format (SYLK / WK# / Multiplan) minutiae
## v0.18.7
* Normalized handling of `\r` and `\n` newline characters
## v0.18.6
* Removed all npm dependencies
* Auto-correct bad Google Sheets format `d.m`
* NUMBERS write merge cells, cells up to column "ALL"
## v0.18.5
* Enabled `sideEffects: false` in package.json
* Basic NUMBERS write support
## v0.18.4
* CSV output omits trailing record separator
* Properly terminate NodeJS Streams
* DBF preserve column types on import and use when applicable on export
## v0.18.3
* Removed references to `require` and `process` in browser builds
## v0.18.2
* Hotfix for unicode processing of XLSX exports
## v0.18.1
* Removed Node ESM build script and folded into standard ESM build
* Removed undocumented aliases including `make_formulae` and `get_formulae`
## v0.18.0
* Browser scripts only expose `XLSX` variable
* Module no longer ships with `dist/jszip.js` browser script
## v0.17.4
* CLI script moved to `xlsx-cli` package
## v0.17.3
* `window.XLSX` explicit assignment to satiate LWC
* CSV Proper formatting of errors
* HTML emit data-\* attributes
## v0.17.2
* Browser and Node optional ESM support
* DSV correct handling of bare quotes (h/t @bgamrat)
## v0.17.1
* `XLSB` writer uses short cell form when viable
## 0.17.0:
* mini build includes ODS parse/write support
* DBF explicitly cap worksheet to 1<<20 rows
* XLS throw errors on truncated records
## v0.16.2
* Disabled `PRN` parsing by default (better support for CSV without delimeters)
## v0.16.1
* skip empty custom property tags if data is absent (fixes DocSecurity issue)
* HTML output add raw value, type, number format
* DOM parse look for `v` / `t` / `z` attributes when determining value
* double quotes in properties escaped using `_x0022_`
* changed AMD structure for NetSuite and other RequireJS implementations
- `encode_cell` and `decode_cell` do not rely on `encode_col` / `decode_col`
## v0.16.0
* Date handling changed
* XLML certain tag tests are now case insensitive
* Fixed potentially vulnerable regular expressions
## v0.15.6
* CFB prevent infinite loop
* ODS empty cells marked as stub (type "z")
* `cellStyles` option implies `sheetStubs`
## v0.15.5
* `sheets` parse option to specify which sheets to parse
## v0.15.4
* AOA utilities properly preserve number formats
* Number formats captured in stub cells
## v0.15.3
* Properties and Custom Properties properly XML-encoded
## v0.15.2
- `sheet_get_cell` utility function
- `sheet_to_json` explicitly support `null` as alias for default behavior
- `encode_col` throw on negative column index
- HTML properly handle whitespace around tags in a run
- HTML use `id` option on write
- Files starting with `0x09` followed by a display character are now TSV files
- XLS parse references col/row indices mod by the correct number for BIFF ver
- XLSX comments moved to avoid overlapping cell
- XLSB outline level
- AutoFilter update `_FilterDatabase` defined name on write
- XLML skip CDATA blocks
## v0.15.1 (2019-08-14)
* XLSX ignore XML artifacts
* HTML capture and persist merges
## v0.15.0
* `dist/xlsx.mini.min.js` mini build with XLSX read/write and some utilities
* Removed legacy conversion utility functions
## v0.14.5
* XLS PtgNameX lookup
* XLS always create stub cells for blank cells with comments
## v0.14.4
* Better treatment of `skipHidden` in CSV output
* Ignore CLSID in XLS
* SYLK 7-bit character encoding
* SYLK and DBF codepage support
## v0.14.3
* Proper shifting of addresses in Shared Formulae
## v0.14.2
* Proper XML encoding of comments
## v0.14.1
* raw cell objects can be passed to `sheet_add_aoa`
* `_FilterDatabase` fix for AutoFilter-related crashes
* `stream.to_json` doesn't end up accidentally scanning to max row
## 0.14.0 (2018-09-06)
* `sheet_to_json` default flipped to `raw: true`
## 0.13.5 (2018-08-25)
* HTML output generates `<br/>` instead of encoded newline character
## 0.13.2 (2018-07-08)
* Buffer.from shim replaced, will not be defined in node `<=0.12`
## 0.13.0 (2018-06-01)
* Library reshaped to support AMD out of the box
## 0.12.11 (2018-04-27)
* XLS/XLSX/XLSB range truncation (errors in `WTF` mode)
## 0.12.4 (2018-03-04)
* `JSZip` renamed to `JSZipSync`
## 0.12.0 (2018-02-08)
* Extendscript target script in NPM package
## 0.11.19 (2018-02-03)
* Error on empty workbook
## 0.11.16 (2017-12-30)
* XLS ANSI/CP separation
* 'array' write type and ArrayBuffer processing
## 0.11.6 (2017-10-16)
* Semicolon-delimited files are detected
## 0.11.5 (2017-09-30)
* Bower main script shifted to full version
* 'binary' / 'string' encoding
## 0.11.3 (2017-08-19)
* XLS cell ixfe/XF removed
## 0.11.0 (2017-07-31)
* Strip `require` statements from minified version
* minifier mangler enabled
## 0.10.9 (2017-07-28)
* XLML/HTML resolution logic looks further into the data stream to decide type
* Errors thrown on suspected RTF files
## 0.10.5 (2017-06-09)
* HTML Table output header/footer should not include `<table>` tag
## 0.10.2 (2017-05-16)
* Dates are converted to numbers by default (set `cellDates:true` to emit Dates)
* Module does not export CFB
## 0.9.10 (2017-04-08)
* `--perf` renamed to `--read-only`
## 0.9.9 (2017-04-03)
* default output format changed to XLSB
* comment text line endings are now normalized
* errors thrown on write when worksheets have invalid names
## 0.9.7 (2017-03-28)
* XLS legacy `!range` field removed
* Hyperlink tooltip is stored in the `Tooltip` field
## 0.9.6 (2017-03-25)
* `sheet_to_json` now passes `null` values when `raw` is set to `true`
* `sheet_to_json` treats `null` stub cells as values in conjunction with `raw`
## 0.9.5 (2017-03-22)
* `cellDates` affects parsing in non-XLSX formats
## 0.9.3 (2017-03-15)
* XLML property names are more closely mapped to the XLSX equivalent
* Stub cells are now cell type `z`
## 0.9.2 (2017-03-13)
* Removed stale TypeScript definition files. Flowtype comments are used in the
`xlsx.flow.js` source and stripped to produce `xlsx.js`.
* sed usage reworked to support GNU sed in-place form. BSD sed seems to work,
but the build script has not been tested on other sed variants:
```bash
$ sed -i.ext [...] # GNU
$ sed -i .ext [...] # bsd
```
## 0.9.0 (2017-03-09)
* Removed ods.js source. The xlsx.js source absorbed the ODS logic and exposes
the ODS variable, so projects should remove references to ods.js

View 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) 2012-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.

View File

@@ -0,0 +1,40 @@
# [SheetJS](https://sheetjs.com)
The SheetJS Community Edition offers battle-tested open-source solutions for
extracting useful data from almost any complex spreadsheet and generating new
spreadsheets that will work with legacy and modern software alike.
[SheetJS Pro](https://sheetjs.com/pro) offers solutions beyond data processing:
Edit complex templates with ease; let out your inner Picasso with styling; make
custom sheets with images/graphs/PivotTables; evaluate formula expressions and
port calculations to web apps; automate common spreadsheet tasks, and much more!
[![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/sheetjs?pixel)](https://github.com/SheetJS/sheetjs)
[![Build Status](https://saucelabs.com/browser-matrix/sheetjs.svg)](https://saucelabs.com/u/sheetjs)
## Documentation
- [API and Usage Documentation](https://docs.sheetjs.com)
- [Downloadable Scripts and Modules](https://cdn.sheetjs.com)
## Related Projects
- <https://oss.sheetjs.com/notes/>: File Format Notes
- [`ssf`](packages/ssf): Format data using ECMA-376 spreadsheet format codes
- [`xlsx-cli`](packages/xlsx-cli/): NodeJS command-line tool for processing files
- [`test_files`](https://github.com/SheetJS/test_files): Sample spreadsheets
- [`cfb`](https://github.com/SheetJS/js-cfb): Container (OLE/ZIP) format library
- [`codepage`](https://github.com/SheetJS/js-codepage): Legacy text encodings
## 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.

View File

@@ -0,0 +1,310 @@
#!/usr/bin/env node
/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
/* eslint-env node */
/* vim: set ts=2 ft=javascript: */
var n = "xlsx";
var X = require('../');
try { X = require('../xlsx.flow'); } catch(e) {}
try { require('exit-on-epipe'); } catch(e) {}
var fs = require('fs'), program;
try { program = require('commander'); } catch(e) {
[
"The `xlsx` command line tool is deprecated in favor of `xlsx-cli`.",
"",
"For new versions of node, we recommend using `npx`:",
" $ npx xlsx-cli --help",
"",
"For older versions of node, explicitly install `xlsx-cli` globally:",
" $ npm i -g xlsx-cli",
" $ xlsx-cli --help"
].forEach(function(m) { console.error(m); });
process.exit(1);
}
program
.version(X.version)
.usage('[options] <file> [sheetname]')
.option('-f, --file <file>', 'use specified workbook')
.option('-s, --sheet <sheet>', 'print specified sheet (default first sheet)')
.option('-N, --sheet-index <idx>', 'use specified sheet index (0-based)')
.option('-p, --password <pw>', 'if file is encrypted, try with specified pw')
.option('-l, --list-sheets', 'list sheet names and exit')
.option('-o, --output <file>', 'output to specified file')
.option('-B, --xlsb', 'emit XLSB to <sheetname> or <file>.xlsb')
.option('-M, --xlsm', 'emit XLSM to <sheetname> or <file>.xlsm')
.option('-X, --xlsx', 'emit XLSX to <sheetname> or <file>.xlsx')
.option('-I, --xlam', 'emit XLAM to <sheetname> or <file>.xlam')
.option('-Y, --ods', 'emit ODS to <sheetname> or <file>.ods')
.option('-8, --xls', 'emit XLS to <sheetname> or <file>.xls (BIFF8)')
.option('-5, --biff5','emit XLS to <sheetname> or <file>.xls (BIFF5)')
.option('-4, --biff4','emit XLS to <sheetname> or <file>.xls (BIFF4)')
.option('-3, --biff3','emit XLS to <sheetname> or <file>.xls (BIFF3)')
.option('-2, --biff2','emit XLS to <sheetname> or <file>.xls (BIFF2)')
.option('-i, --xla', 'emit XLA to <sheetname> or <file>.xla')
.option('-6, --xlml', 'emit SSML to <sheetname> or <file>.xls (2003 XML)')
.option('-T, --fods', 'emit FODS to <sheetname> or <file>.fods (Flat ODS)')
.option('--wk3', 'emit WK3 to <sheetname> or <file>.txt (Lotus WK3)')
.option('--numbers', 'emit NUMBERS to <sheetname> or <file>.numbers')
.option('-S, --formulae', 'emit list of values and formulae')
.option('-j, --json', 'emit formatted JSON (all fields text)')
.option('-J, --raw-js', 'emit raw JS object (raw numbers)')
.option('-A, --arrays', 'emit rows as JS objects (raw numbers)')
.option('-H, --html', 'emit HTML to <sheetname> or <file>.html')
.option('-D, --dif', 'emit DIF to <sheetname> or <file>.dif (Lotus DIF)')
.option('-U, --dbf', 'emit DBF to <sheetname> or <file>.dbf (MSVFP DBF)')
.option('-K, --sylk', 'emit SYLK to <sheetname> or <file>.slk (Excel SYLK)')
.option('-P, --prn', 'emit PRN to <sheetname> or <file>.prn (Lotus PRN)')
.option('-E, --eth', 'emit ETH to <sheetname> or <file>.eth (Ethercalc)')
.option('-t, --txt', 'emit TXT to <sheetname> or <file>.txt (UTF-8 TSV)')
.option('-r, --rtf', 'emit RTF to <sheetname> or <file>.txt (Table RTF)')
.option('--wk1', 'emit WK1 to <sheetname> or <file>.txt (Lotus WK1)')
.option('-z, --dump', 'dump internal representation as JSON')
.option('--props', 'dump workbook properties as CSV')
.option('-F, --field-sep <sep>', 'CSV field separator', ",")
.option('-R, --row-sep <sep>', 'CSV row separator', "\n")
.option('-n, --sheet-rows <num>', 'Number of rows to process (0=all rows)')
.option('--codepage <cp>', 'default to specified codepage when ambiguous')
.option('--req <module>', 'require module before processing')
.option('--sst', 'generate shared string table for XLS* formats')
.option('--compress', 'use compression when writing XLSX/M/B and ODS')
.option('--read', 'read but do not generate output')
.option('--book', 'for single-sheet formats, emit a file per worksheet')
.option('--all', 'parse everything; write as much as possible')
.option('--dev', 'development mode')
.option('--sparse', 'sparse mode')
.option('-q, --quiet', 'quiet mode');
program.on('--help', function() {
console.log(' Default output format is CSV');
console.log(' Support email: dev@sheetjs.com');
console.log(' Web Demo: http://oss.sheetjs.com/js-'+n+'/');
});
/* flag, bookType, default ext */
var workbook_formats = [
['xlsx', 'xlsx', 'xlsx'],
['xlsm', 'xlsm', 'xlsm'],
['xlam', 'xlam', 'xlam'],
['xlsb', 'xlsb', 'xlsb'],
['xls', 'xls', 'xls'],
['xla', 'xla', 'xla'],
['biff5', 'biff5', 'xls'],
['numbers', 'numbers', 'numbers'],
['ods', 'ods', 'ods'],
['fods', 'fods', 'fods'],
['wk3', 'wk3', 'wk3']
];
var wb_formats_2 = [
['xlml', 'xlml', 'xls']
];
program.parse(process.argv);
var filename = '', sheetname = '';
if(program.args[0]) {
filename = program.args[0];
if(program.args[1]) sheetname = program.args[1];
}
if(program.sheet) sheetname = program.sheet;
if(program.file) filename = program.file;
if(!filename) {
console.error(n + ": must specify a filename");
process.exit(1);
}
if(!fs.existsSync(filename)) {
console.error(n + ": " + filename + ": No such file or directory");
process.exit(2);
}
if(program.req) program.req.split(",").forEach(function(r) {
require((fs.existsSync(r) || fs.existsSync(r + '.js')) ? require('path').resolve(r) : r);
});
var opts = {}, wb/*:?Workbook*/;
if(program.listSheets) opts.bookSheets = true;
if(program.sheetRows) opts.sheetRows = program.sheetRows;
if(program.password) opts.password = program.password;
var seen = false;
function wb_fmt() {
seen = true;
opts.cellFormula = true;
opts.cellNF = true;
opts.xlfn = true;
if(program.output) sheetname = program.output;
}
function isfmt(m/*:string*/)/*:boolean*/ {
if(!program.output) return false;
var t = m.charAt(0) === "." ? m : "." + m;
return program.output.slice(-t.length) === t;
}
workbook_formats.forEach(function(m) { if(program[m[0]] || isfmt(m[0])) { wb_fmt(); } });
wb_formats_2.forEach(function(m) { if(program[m[0]] || isfmt(m[0])) { wb_fmt(); } });
if(seen) {
} else if(program.formulae) opts.cellFormula = true;
else opts.cellFormula = false;
var wopts = ({WTF:opts.WTF, bookSST:program.sst}/*:any*/);
if(program.compress) wopts.compression = true;
if(program.all) {
opts.cellFormula = true;
opts.bookVBA = true;
opts.cellNF = true;
opts.cellHTML = true;
opts.cellStyles = true;
opts.sheetStubs = true;
opts.cellDates = true;
wopts.cellFormula = true;
wopts.cellStyles = true;
wopts.sheetStubs = true;
wopts.bookVBA = true;
}
if(program.sparse) opts.dense = false; else opts.dense = true;
if(program.codepage) opts.codepage = +program.codepage;
if(program.dev) {
opts.WTF = true;
wb = X.readFile(filename, opts);
} else try {
wb = X.readFile(filename, opts);
} catch(e) {
var msg = (program.quiet) ? "" : n + ": error parsing ";
msg += filename + ": " + e;
console.error(msg);
process.exit(3);
}
if(program.read) process.exit(0);
if(!wb) { console.error(n + ": error parsing " + filename + ": empty workbook"); process.exit(0); }
/*:: if(!wb) throw new Error("unreachable"); */
if(program.listSheets) {
console.log((wb.SheetNames||[]).join("\n"));
process.exit(0);
}
if(program.dump) {
console.log(JSON.stringify(wb));
process.exit(0);
}
if(program.props) {
if(wb) dump_props(wb);
process.exit(0);
}
/* full workbook formats */
workbook_formats.forEach(function(m) { if(program[m[0]] || isfmt(m[0])) {
wopts.bookType = m[1];
if(wopts.bookType == "numbers") try {
var XLSX_ZAHL = require("../dist/xlsx.zahl");
wopts.numbers = XLSX_ZAHL;
} catch(e) {}
if(wb) X.writeFile(wb, program.output || sheetname || ((filename || "") + "." + m[2]), wopts);
process.exit(0);
} });
wb_formats_2.forEach(function(m) { if(program[m[0]] || isfmt(m[0])) {
wopts.bookType = m[1];
if(wb) X.writeFile(wb, program.output || sheetname || ((filename || "") + "." + m[2]), wopts);
process.exit(0);
} });
var target_sheet = sheetname || '';
if(target_sheet === '') {
if(+program.sheetIndex < (wb.SheetNames||[]).length) target_sheet = wb.SheetNames[+program.sheetIndex];
else target_sheet = (wb.SheetNames||[""])[0];
}
var ws;
try {
ws = wb.Sheets[target_sheet];
if(!ws) {
console.error("Sheet " + target_sheet + " cannot be found");
process.exit(3);
}
} catch(e) {
console.error(n + ": error parsing "+filename+" "+target_sheet+": " + e);
process.exit(4);
}
if(!program.quiet && !program.book) console.error(target_sheet);
/* single worksheet file formats */
[
['biff2', '.xls'],
['biff3', '.xls'],
['biff4', '.xls'],
['sylk', '.slk'],
['html', '.html'],
['prn', '.prn'],
['eth', '.eth'],
['rtf', '.rtf'],
['txt', '.txt'],
['dbf', '.dbf'],
['wk1', '.wk1'],
['dif', '.dif']
].forEach(function(m) { if(program[m[0]] || isfmt(m[1])) {
wopts.bookType = m[0];
if(program.book) {
/*:: if(wb == null) throw new Error("Unreachable"); */
wb.SheetNames.forEach(function(n, i) {
wopts.sheet = n;
X.writeFile(wb, (program.output || sheetname || filename || "") + m[1] + "." + i, wopts);
});
} else X.writeFile(wb, program.output || sheetname || ((filename || "") + m[1]), wopts);
process.exit(0);
} });
function outit(o, fn) { if(fn) fs.writeFileSync(fn, o); else console.log(o); }
function doit(cb) {
/*:: if(!wb) throw new Error("unreachable"); */
if(program.book) wb.SheetNames.forEach(function(n, i) {
/*:: if(!wb) throw new Error("unreachable"); */
outit(cb(wb.Sheets[n]), (program.output || sheetname || filename) + "." + i);
});
else outit(cb(ws), program.output);
}
var jso = {};
switch(true) {
case program.formulae:
doit(function(ws) { return X.utils.sheet_to_formulae(ws).join("\n"); });
break;
case program.arrays: jso.header = 1;
/* falls through */
case program.rawJs: jso.raw = true;
/* falls through */
case program.json:
doit(function(ws) { return JSON.stringify(X.utils.sheet_to_json(ws,jso)); });
break;
default:
if(!program.book) {
var stream = X.stream.to_csv(ws, {FS:program.fieldSep||",", RS:program.rowSep||"\n"});
if(program.output) stream.pipe(fs.createWriteStream(program.output));
else stream.pipe(process.stdout);
} else doit(function(ws) { return X.utils.sheet_to_csv(ws,{FS:program.fieldSep, RS:program.rowSep}); });
break;
}
function dump_props(wb/*:Workbook*/) {
var propaoa = [];
if(Object.assign && Object.entries) propaoa = Object.entries(Object.assign({}, wb.Props, wb.Custprops));
else {
var Keys/*:: :Array<string> = []*/, pi;
if(wb.Props) {
Keys = Object.keys(wb.Props);
for(pi = 0; pi < Keys.length; ++pi) {
if(Object.prototype.hasOwnProperty.call(Keys, Keys[pi])) propaoa.push([Keys[pi], Keys[/*::+*/Keys[pi]]]);
}
}
if(wb.Custprops) {
Keys = Object.keys(wb.Custprops);
for(pi = 0; pi < Keys.length; ++pi) {
if(Object.prototype.hasOwnProperty.call(Keys, Keys[pi])) propaoa.push([Keys[pi], Keys[/*::+*/Keys[pi]]]);
}
}
}
console.log(X.utils.sheet_to_csv(X.utils.aoa_to_sheet(propaoa)));
}

View File

@@ -0,0 +1,22 @@
{
"name": "js-xlsx",
"homepage": "https://github.com/SheetJS/js-xlsx",
"main": ["xlsx.js"],
"ignore": [
"bin",
"bits",
"misc",
"**/.*"
],
"keywords": [
"excel",
"xls",
"xml",
"xlsx",
"xlsm",
"xlsb",
"ods",
"js-xls",
"js-xlsx"
]
}

View 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) 2012-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.

View File

@@ -0,0 +1,39 @@
/* codepage.js (C) 2013-present SheetJS -- http://sheetjs.com */
// TypeScript Version: 2.2
/** Codepage index type (integer or string representation) */
export type CP$Index = number | string;
/* Individual codepage converter */
export interface CP$Conv {
enc: {[n: string]: number; };
dec: {[n: number]: string; };
}
/** Encode input type (string, array of characters, Buffer) */
export type CP$String = string | string[] | Uint8Array;
/** Encode output / decode input type */
export type CP$Data = string | number[] | Uint8Array;
/** General utilities */
export interface CP$Utils {
decode(cp: CP$Index, data: CP$Data): string;
encode(cp: CP$Index, data: CP$String, opts?: any): CP$Data;
hascp(n: number): boolean;
magic: {[cp: string]: string};
}
/* note: TS cannot export top-level indexer, hence default workaround */
export interface CP$Module {
/** Version string */
version: string;
/** Utility Functions */
utils: CP$Utils;
/** Codepage Converters */
[cp: number]: CP$Conv;
}
export const cptable: CP$Module;
export default cptable;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,4 @@
/* zahl.d.ts (C) 2022-present SheetJS */
// TypeScript Version: 2.2
declare const XLSX_ZAHL_PAYLOAD: string;
export default XLSX_ZAHL_PAYLOAD;

View File

@@ -0,0 +1,147 @@
{
"name": "xlsx",
"version": "0.19.3",
"author": "sheetjs",
"description": "SheetJS Spreadsheet data parser and writer",
"keywords": [
"excel",
"xls",
"xlsx",
"xlsb",
"xlsm",
"ods",
"csv",
"dbf",
"dif",
"sylk",
"office",
"spreadsheet"
],
"bin": {
"xlsx": "./bin/xlsx.njs"
},
"main": "xlsx.js",
"module": "xlsx.mjs",
"unpkg": "dist/xlsx.full.min.js",
"jsdelivr": "dist/xlsx.full.min.js",
"types": "types/index.d.ts",
"exports": {
".": {
"import": "./xlsx.mjs",
"require": "./xlsx.js",
"types": "./types/index.d.ts"
},
"./xlsx.mjs": {
"import": "./xlsx.mjs",
"types": "./types/index.d.ts"
},
"./xlsx.js": {
"require": "./xlsx.js",
"types": "./types/index.d.ts"
},
"./dist/xlsx.zahl": {
"import": "./dist/xlsx.zahl.mjs",
"require": "./dist/xlsx.zahl.js",
"types": "./dist/zahl.d.ts"
},
"./dist/xlsx.zahl.mjs": {
"import": "./dist/xlsx.zahl.mjs",
"types": "./dist/zahl.d.ts"
},
"./dist/xlsx.zahl.js": {
"require": "./dist/xlsx.zahl.js",
"types": "./dist/zahl.d.ts"
},
"./dist/cpexcel": {
"import": "./dist/cpexcel.full.mjs",
"require": "./dist/cpexcel.js",
"types": "./dist/cpexcel.d.ts"
},
"./dist/cpexcel.js": {
"require": "./dist/cpexcel.js",
"types": "./dist/cpexcel.d.ts"
},
"./dist/cpexcel.full": {
"import": "./dist/cpexcel.full.mjs",
"require": "./dist/cpexcel.js",
"types": "./dist/cpexcel.d.ts"
},
"./dist/cpexcel.full.mjs": {
"import": "./dist/cpexcel.full.mjs",
"types": "./dist/cpexcel.d.ts"
}
},
"browser": {
"buffer": false,
"crypto": false,
"stream": false,
"process": false,
"fs": false
},
"sideEffects": false,
"dependencies": {
},
"devDependencies": {
"@sheetjs/uglify-js": "~2.7.3",
"@types/node": "^8.5.9",
"acorn": "7.4.1",
"adler-32": "~1.3.1",
"alex": "8.1.1",
"blanket": "~1.2.3",
"cfb": "~1.2.2",
"codepage": "~1.15.0",
"commander": "~2.17.1",
"crc-32": "~1.2.2",
"dtslint": "^0.1.2",
"eslint": "7.23.0",
"eslint-plugin-html": "^6.1.2",
"eslint-plugin-json": "^2.1.2",
"exit-on-epipe": "~1.0.1",
"fflate": "^0.7.1",
"jsdom": "~11.1.0",
"markdown-spellcheck": "^1.3.1",
"mocha": "~2.5.3",
"sinon": "^1.17.7",
"ssf": "~0.11.2",
"typescript": "2.2.0",
"wmf": "~1.0.1",
"word": "~0.3.0"
},
"repository": {
"type": "git",
"url": "https://git.sheetjs.com/SheetJS/sheetjs"
},
"scripts": {
"pretest": "npm run lint",
"test": "npm run tests-only",
"pretest-only": "git submodule init && git submodule update",
"tests-only": "make travis",
"build": "make",
"lint": "make fullint",
"dtslint": "dtslint types"
},
"config": {
"blanket": {
"pattern": "xlsx.js"
}
},
"alex": {
"allow": [
"chinese",
"special",
"simple",
"just",
"crash",
"wtf",
"holes"
]
},
"homepage": "https://sheetjs.com/",
"bugs": {
"url": "https://git.sheetjs.com/SheetJS/sheetjs/issues"
},
"license": "Apache-2.0",
"engines": {
"node": ">=0.8"
}
}

View File

@@ -0,0 +1,990 @@
/* index.d.ts (C) 2015-present SheetJS and contributors */
// TypeScript Version: 2.2
// import * as CFB from "cfb";
// import * as SSF from "ssf";
/** Version string */
export const version: string;
/** SSF Formatter Library */
// export { SSF };
export const SSF: any;
/** CFB Library */
// export { CFB };
export const CFB: any;
/** Set internal `fs` instance */
export function set_fs(fs: any): void;
/** Set internal codepage tables */
export function set_cptable(cptable: any): void;
/** 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 or download workbook data to XLSX file */
export function writeFileXLSX(data: WorkBook, filename: string, opts?: WritingOptions): any;
/** Attempts to write or download workbook data to file asynchronously */
type CBFunc = () => void;
export function writeFileAsync(filename: string, data: WorkBook, opts: WritingOptions | CBFunc, cb?: CBFunc): any;
/** Attempts to write the workbook data */
export function write(data: WorkBook, opts: WritingOptions): any;
/** Attempts to write the workbook data as XLSX */
export function writeXLSX(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;
/** Worksheet specifier (string, number, worksheet) */
export type WSSpec = string | number | WorkSheet;
/** Range specifier (string or range or cell), single-cell lifted to range */
export type RangeSpec = string | Range | CellAddress;
/** 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;
/**
* Create cell objects for stub cells
* @default false
*/
sheetStubs?: 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;
/**
* If defined and file is encrypted, use password
* @default ''
*/
password?: string;
}
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 for legacy files
*
* This requires encoding support to be loaded. It is automatically loaded
* in `xlsx.full.min.js` and in CommonJS / Extendscript, but an extra step
* is required in React / Angular / Webpack ESM deployments.
*
* Check the relevant guide https://docs.sheetjs.com/docs/getting-started/
*/
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;
/** Field Separator ("Delimiter" override) */
FS?: string;
/**
* 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 specified, only parse the specified sheets or sheet names */
sheets?: number | string | Array<number | string>;
/** If true, plaintext parsing will not parse values */
raw?: boolean;
/** If true, ignore "dimensions" records and guess range using every cell */
nodim?: boolean;
/** If true, preserve _xlfn. prefixes in formula function names */
xlfn?: boolean;
/** If true, generate dense-mode worksheets */
dense?: boolean;
/**
* For single-sheet formats (including CSV), override the worksheet name
* @default "Sheet1"
*/
sheet?: string;
PRN?: 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;
/**
* 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;
/**
* Desired codepage for legacy file formats
*
* This requires encoding support to be loaded. It is automatically loaded
* in `xlsx.full.min.js` and in CommonJS / Extendscript, but an extra step
* is required in React / Angular / Webpack / ESM deployments.
*
* Check the relevant guide https://docs.sheetjs.com/docs/getting-started/
*/
codepage?: number;
/** Base64 encoding of NUMBERS base for exports */
numbers?: string;
/**
* For single-sheet formats, export the specified worksheet.
*
* The property must be a string (sheet name) or number (`SheetNames` index).
*
* If this option is omitted, the first worksheet will be exported.
*/
sheet?: string | number;
}
/** 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;
/** Original file type (when parsed with `read` or `readFile`) */
bookType?: BookType;
}
export interface SheetProps {
/** Name of Sheet */
name?: string;
/** 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;
}
/** DBF Field Header */
export interface DBFField {
/** Original Field Name */
name?: string;
/** Field Type */
type?: string;
/** Field Length */
len?: number;
/** Field Decimal Count */
dec?: number;
}
/** 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;
/** outline / group level */
level?: number;
/** Excel's "Max Digit Width" unit, always integral */
MDW?: number;
/** DBF Field Header */
DBF?: DBFField;
}
/** 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 {
/**
* Sparse-mode store cells with keys corresponding to A1-style address
* Dense-mode store cells in the '!data' key
* Special keys start with '!'
*/
[cell: string]: CellObject | CellObject[][] | SheetKeys | any;
/**
* Dense-mode worksheets store data in an array of arrays
*
* Cells are accessed with sheet['!data'][R][C] (where R and C are 0-indexed)
*/
'!data'?: CellObject[][];
/** Sheet type */
'!type'?: SheetType;
/** Sheet Range (A1-style) */
'!ref'?: string;
/** Page Margins */
'!margins'?: MarginInfo;
}
/** General object representing a dense Sheet (worksheet or chartsheet) */
export interface DenseSheet extends Sheet {
/**
* Special keys start with '!'
* Dense-mode worksheets store data in the '!data' key
*/
[cell: string]: CellObject[][] | SheetKeys | any;
/**
* Dense-mode worksheets store data in an array of arrays
*
* Cells are accessed with sheet['!data'][R][C] (where R and C are 0-indexed)
*/
'!data': CellObject[][];
}
/** General object representing a sparse Sheet (worksheet or chartsheet) */
export interface SparseSheet extends Sheet {
/**
* Sparse-mode store cells with keys corresponding to A1-style address
* Cells are accessed with sheet[addr]
*/
'!data': never;
}
/** 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;
}
/** Dense Worksheet Object */
export interface DenseWorkSheet extends DenseSheet {
/**
* Dense-mode worksheets store data in an array of arrays
*
* Cells are accessed with sheet['!data'][R][C] (where R and C are 0-indexed)
*/
'!data': CellObject[][];
}
/**
* Worksheet Object with CellObject type
*
* The normal Worksheet type uses indexer of type `any` -- this enforces CellObject
*/
export interface StrictWS { [addr: string]: CellObject; }
/**
* 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' | 'slk' | 'html' | 'dif' | 'rtf' | 'prn' | 'eth' | 'dbf' | 'numbers';
/** Comment element */
export interface Comment {
/** Author of the comment block */
a?: string;
/** Plaintext of the comment */
t: string;
/** If true, mark the comment as a part of a thread */
T?: boolean;
}
/** Cell comments */
export interface Comments extends Array<Comment> {
/** Hide comment by default */
hidden?: boolean;
}
/** 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;
/** If true, cell is a dynamic array formula (for supported file formats) */
D?: boolean;
/** Rich text encoding (if applicable) */
r?: any;
/** HTML rendering of the rich text (if applicable) */
h?: string;
/** Comments associated with the cell */
c?: Comments;
/** 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;
/** Force quotes around fields */
forceQuotes?: boolean;
/** if true, return raw numbers; if false, return formatted numbers */
rawNumbers?: 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;
/** if true, skip hidden rows and columns */
skipHidden?: boolean;
/** if true, return raw numbers; if false, return formatted numbers */
rawNumbers?: 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, OriginOption {
/** Use specified column order */
header?: string[];
/** Skip header row in generated sheet */
skipHeader?: boolean;
}
export interface Table2SheetOpts extends CommonOptions, DateNFOption, OriginOption {
/** 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;
/**
* Override the worksheet name
* @default "Sheet1"
*/
sheet?: string;
}
export interface Table2BookOpts extends Table2SheetOpts {
/**
* Override the worksheet name
* @default "Sheet1"
*/
sheet?: string;
}
/** 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?: Table2BookOpts): WorkBook;
sheet_add_dom(ws: WorkSheet, data: any, opts?: Table2SheetOpts): WorkSheet;
/* --- 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, returns new worksheet name */
book_append_sheet(workbook: WorkBook, worksheet: WorkSheet, name?: string, roll?: boolean): string;
/** 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, dynamic?: boolean): 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?: JSON2SheetOpts): WorkSheet;
sheet_add_json<T>(ws: WorkSheet, data: T[], opts?: JSON2SheetOpts): 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;
/** Set `Readable` (internal) */
set_readable(Readable: any): void;
}

View File

@@ -0,0 +1,15 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [ "es5" ],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": ".",
"paths": { "xlsx": ["."] },
"types": [],
"noEmit": true,
"strictFunctionTypes": true,
"forceConsistentCasingInFileNames": true
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,14 @@
/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
importScripts('dist/shim.min.js');
/* uncomment the next line for encoding support */
importScripts('dist/cpexcel.js');
importScripts('xlsx.js');
postMessage({t:"ready"});
onmessage = function (evt) {
var v;
try {
v = XLSX.read(evt.data.d, {type: evt.data.b, codepage: evt.data.c});
postMessage({t:"xlsx", d:JSON.stringify(v)});
} catch(e) { postMessage({t:"e",d:e.stack||e}); }
};

View File

@@ -0,0 +1,41 @@
{
"name": "node-red-contrib-spreadsheet-in",
"version": "0.7.2",
"description": "This package provides Node-RED nodes to read data from spreadsheet (Excel, ODS, etc.) file.",
"main": "node.js",
"scripts": {
"test": "mocha \"test/**/*_spec.js\""
},
"repository": {
"type": "git",
"url": "git+https://github.com/sakai-to/node-red-contrib-spreadsheet-in.git"
},
"keywords": [
"node-red",
"spreadsheet",
"excel"
],
"author": "sakai.to",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/sakai-to/node-red-contrib-spreadsheet-in/issues"
},
"homepage": "https://github.com/sakai-to/node-red-contrib-spreadsheet-in#readme",
"node-red": {
"nodes": {
"book": "book.js",
"sheet": "sheet.js",
"cell": "cell.js",
"sheet-to-json": "sheet-to-json.js"
}
},
"dependencies": {
"xlsx": "https://cdn.sheetjs.com/xlsx-0.19.3/xlsx-0.19.3.tgz"
},
"devDependencies": {
"mocha": "^8.2.1",
"node-red": "^1.2.6",
"node-red-node-test-helper": "^0.2.5",
"should": "^13.2.3"
}
}

View File

@@ -0,0 +1,59 @@
<script type="text/javascript">
RED.nodes.registerType('sheet-to-json',{
category: 'Spreadsheet',
color: "#DEBD5C",
defaults: {
name: {value:""},
raw: {value:"false", required:true},
range: {value:""},
header: {value:"default", required:true},
blankrows: {value:false, required:true}
},
inputs:1,
outputs:1,
icon: "font-awesome/fa-sign-out",
label: function() {
return this.name||"sheet to json";
},
labelStyle: function() {
return this.name?"node_label_italic":"";
},
inputLabels: function() {
return this._("sheet-to-json.label.sheetObject");
},
outputLabels: function () {
return this._("sheet-to-json.label.cellValues");
}
});
</script>
<script type="text/x-red" data-template-name="sheet-to-json">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
</div>
<div class="form-row">
<label for="node-input-raw"><i class="fa fa-sign-out"></i> <span data-i18n="sheet-to-json.label.raw"></span></label>
<select id="node-input-raw">
<option value="false" data-i18n="sheet-to-json.raw.false"></option>
<option value="true" data-i18n="sheet-to-json.raw.true"></option>
</select>
</div>
<div class="form-row">
<label for="node-input-range"><i class="fa fa-th-large"></i> <span data-i18n="sheet-to-json.label.range"></span></label>
<input type="text" id="node-input-range" data-i18n="[placeholder]sheet-to-json.placeholder.range">
</div>
<div class="form-row">
<label for="node-input-header"><i class="fa fa-columns"></i> <span data-i18n="sheet-to-json.label.header"></span></label>
<select id="node-input-header" style="width: 70%">
<option value="1" data-i18n="sheet-to-json.header.1"></option>
<option value="A" data-i18n="sheet-to-json.header.A"></option>
<option value="default" data-i18n="sheet-to-json.header.default"></option>
</select>
</div>
<div class="form-row">
<label><i class="fa fa-bars"></i> <span data-i18n="sheet-to-json.label.blankrows"></span></label>
<input type="checkbox" id="node-input-blankrows" style="width:auto">
<label for="node-input-blankrows" style="width:auto" data-i18n="sheet-to-json.blankrows.include"></label>
</div>
</script>

View File

@@ -0,0 +1,31 @@
module.exports = function(RED) {
const XLSX = require('xlsx');
function convertHeaderParam(value) {
switch (value) {
case "1": return 1;
case "A": return "A";
default: return undefined;
}
}
function SheetToJsonNode(config) {
RED.nodes.createNode(this,config);
var node = this;
node.on('input', function(msg) {
var option = {
raw: config.raw == "true",
range: config.range || msg.selectRange,
header: convertHeaderParam(config.header),
dateNF: undefined,
defval: undefined,
blankrows: config.blankrows == "true"
};
delete msg.selectRange;
msg.payload = XLSX.utils.sheet_to_json(msg.payload, option);
msg.selectedRange = option.range;
node.send(msg);
});
}
RED.nodes.registerType("sheet-to-json",SheetToJsonNode);
}

View File

@@ -0,0 +1,36 @@
<script type="text/javascript">
RED.nodes.registerType('sheet',{
category: 'Spreadsheet',
color: "#DEBD5C",
defaults: {
name: {value:""},
sheetName: {value:"Sheet1"}
},
inputs:1,
outputs:1,
icon: "font-awesome/fa-table",
label: function() {
return this.name||"sheet";
},
labelStyle: function() {
return this.name?"node_label_italic":"";
},
inputLabels: function() {
return this._("sheet.label.workbookObject");
},
outputLabels: function () {
return this._("sheet.label.sheetObject");
}
});
</script>
<script type="text/x-red" data-template-name="sheet">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
</div>
<div class="form-row">
<label for="node-input-sheetName"><i class="icon-tag"></i> <span data-i18n="sheet.label.sheetName"></span></label>
<input type="text" id="node-input-sheetName" data-i18n="[placeholder]sheet.placeholder.sheetName">
</div>
</script>

16
node_modules/node-red-contrib-spreadsheet-in/sheet.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
module.exports = function(RED) {
const util = require('util');
function SheetNode(config) {
RED.nodes.createNode(this,config);
var node = this;
node.on('input', function(msg) {
var sheetName = config.sheetName || msg.selectSheetName;
delete msg.selectSheetName;
msg.payload = msg.payload.Sheets && msg.payload.Sheets[sheetName];
msg.selectedSheetName = sheetName;
node.send(msg);
});
}
RED.nodes.registerType("sheet",SheetNode);
}

View File

@@ -0,0 +1,129 @@
var should = require("should");
var helper = require("node-red-node-test-helper");
var bookNode = require("../book.js");
var fs = require("fs");
helper.init(require.resolve('node-red'));
describe('book Node', function () {
before(function (done) {
helper.startServer(done);
});
after(function (done) {
helper.stopServer(done);
});
afterEach(function () {
helper.unload();
});
it('should be loaded', function (done) {
var flow = [{ id: "n1", type: "book", name: "book1" }];
helper.load(bookNode, flow, function () {
var n1 = helper.getNode("n1");
n1.should.have.property('name', 'book1');
done();
});
});
it('should parse data of a spreadsheet', function (done) {
var flow = [
{ id: "n1", type: "book", name: "book1", wires: [["n2"]] },
{ id: "n2", type: "helper" }
];
helper.load(bookNode, flow, function () {
var n2 = helper.getNode("n2");
n2.on("input", function (msg) {
msg.should.have.propertyByPath('payload', 'SheetNames').eql(['Sheet1']);
done();
});
var n1 = helper.getNode("n1");
var data = fs.readFileSync(__dirname + "/example.xlsx");
n1.receive({ payload: data });
});
});
it('should parse date values of a spreadsheet', function (done) {
var flow = [
{ id: "n1", type: "book", name: "book1", wires: [["n2"]] },
{ id: "n2", type: "helper" }
];
helper.load(bookNode, flow, function () {
var n2 = helper.getNode("n2");
n2.on("input", function (msg) {
try {
msg.should.have.propertyByPath('payload', 'Sheets', 'Sheet1', 'A2', 'w').equal('2020/08/01');
msg.should.have.propertyByPath('payload', 'Sheets', 'Sheet1', 'B2', 'w').equal('2020/08/01 0:00:00');
done();
} catch (e) {
done(e);
}
});
var n1 = helper.getNode("n1");
var data = fs.readFileSync(__dirname + "/time_issue.xlsx");
n1.receive({ payload: data });
});
});
it('should parse data of a csv file', function (done) {
var flow = [
{ id: "n1", type: "book", name: "book1", wires: [["n2"]] },
{ id: "n2", type: "helper" }
];
helper.load(bookNode, flow, function () {
var n2 = helper.getNode("n2");
n2.on("input", function (msg) {
try {
msg.should.have.propertyByPath('payload', 'Sheets', 'Sheet1', 'A2', 'v').equal('2020-07-09T20:00:07.000Z');
done();
} catch (e) {
done(e);
}
});
var n1 = helper.getNode("n1");
var data = fs.readFileSync(__dirname + "/time_issue.csv");
n1.receive({ payload: data });
});
});
it('should not parse data of a csv file', function (done) {
var flow = [
{ id: "n1", type: "book", name: "book1", wires: [["n2"]], raw: true },
{ id: "n2", type: "helper" }
];
helper.load(bookNode, flow, function () {
var n2 = helper.getNode("n2");
n2.on("input", function (msg) {
try {
const expected = process.version >= 'v12' ? '2020-07-09T20:00:07.000Z' : 44021.83341435185;
msg.should.have.propertyByPath('payload', 'Sheets', 'Sheet1', 'A2', 'v').equal(expected);
done();
} catch (e) {
done(e);
}
});
var n1 = helper.getNode("n1");
var data = fs.readFileSync(__dirname + "/time_issue.csv");
n1.receive({ payload: data });
});
});
it('should parse an old format XLS file (pre-2007)', function (done) {
var flow = [
{ id: "n1", type: "book", name: "book1", wires: [["n2"]] },
{ id: "n2", type: "helper" }
];
helper.load(bookNode, flow, function () {
var n1 = helper.getNode("n1");
var n2 = helper.getNode("n2");
n2.on("input", function (msg) {
done();
});
var data = fs.readFileSync(__dirname + "/pre-2007.xlsx");
n1.receive({ payload: data });
});
});
});

View File

@@ -0,0 +1,140 @@
var should = require("should");
var helper = require("node-red-node-test-helper");
var bookNode = require("../book.js");
var sheetNode = require("../sheet.js");
var cellNode = require("../cell.js");
var fs = require("fs");
helper.init(require.resolve('node-red'));
describe('cell Node', function () {
before(function (done) {
helper.startServer(done);
});
after(function (done) {
helper.stopServer(done);
});
afterEach(function () {
helper.unload();
});
it('should be loaded', function (done) {
var flow = [{ id: "n1", type: "cell", name: "cell1" }];
helper.load(cellNode, flow, function () {
var n1 = helper.getNode("n1");
n1.should.have.property('name', 'cell1');
done();
});
});
it('should pick the cell value specified in node config', function (done) {
var flow = [
{ id: "n1", type: "book", name: "book1", wires: [["n2"]] },
{ id: "n2", type: "sheet", name: "sheet1", wires: [["n3"]], sheetName: "Sheet1" },
{ id: "n3", type: "cell", name: "cell1", wires: [["n4"]], address: "A1", dataType: "w" },
{ id: "n4", type: "helper" }
];
helper.load([bookNode, sheetNode, cellNode], flow, function () {
var n4 = helper.getNode("n4");
n4.on("input", function (msg) {
msg.should.have.property('payload', 'col1');
done();
});
var n1 = helper.getNode("n1");
var data = fs.readFileSync(__dirname + "/example.xlsx");
n1.receive({ payload: data });
});
});
it('should pick the cell type specified in node config', function (done) {
var flow = [
{ id: "n1", type: "book", name: "book1", wires: [["n2"]] },
{ id: "n2", type: "sheet", name: "sheet1", wires: [["n3"]], sheetName: "Sheet1" },
{ id: "n3", type: "cell", name: "cell1", wires: [["n4"]], address: "A1", dataType: "t" },
{ id: "n4", type: "helper" }
];
helper.load([bookNode, sheetNode, cellNode], flow, function () {
var n4 = helper.getNode("n4");
n4.on("input", function (msg) {
msg.should.have.property('payload', 's');
done();
});
var n1 = helper.getNode("n1");
var data = fs.readFileSync(__dirname + "/example.xlsx");
n1.receive({ payload: data });
});
});
it('should pick the cell value specified in msg object', function (done) {
var flow = [
{ id: "n1", type: "book", name: "book1", wires: [["n2"]] },
{ id: "n2", type: "sheet", name: "sheet1", wires: [["n3"]], sheetName: "Sheet1" },
{ id: "n3", type: "cell", name: "cell1", wires: [["n4"]], address: "", dataType: "w" },
{ id: "n4", type: "helper" }
];
helper.load([bookNode, sheetNode, cellNode], flow, function () {
var n4 = helper.getNode("n4");
n4.on("input", function (msg) {
msg.should.have.property('payload', 'col1');
done();
});
var n1 = helper.getNode("n1");
var data = fs.readFileSync(__dirname + "/example.xlsx");
n1.receive({ payload: data, selectAddress: "A1" });
});
});
it('should log an error due to no address', function (done) {
var flow = [
{ id: "n1", type: "cell", name: "cell1", wires: [["n2"]], address: "", dataType: "w" }
];
helper.load(cellNode, flow, function () {
var n1 = helper.getNode("n1");
n1.receive({});
try {
helper.log().called.should.be.true();
var logEvents = helper.log().args.filter(function (evt) {
return evt[0].type == "cell";
});
logEvents.should.have.length(1);
var msg = logEvents[0][0];
msg.should.have.property('level', helper.log().ERROR);
msg.should.have.property('id', 'n1');
msg.should.have.property('type', 'cell');
msg.should.have.property('msg', 'cell.errors.no-address');
done();
} catch (err) {
done(err);
}
});
});
it('should log an error due to invalid address', function (done) {
var flow = [
{ id: "n1", type: "cell", name: "cell1", wires: [["n2"]], address: "INVARID_ADDRESS", dataType: "w" }
];
helper.load(cellNode, flow, function () {
var n1 = helper.getNode("n1");
n1.receive({});
try {
helper.log().called.should.be.true();
var logEvents = helper.log().args.filter(function (evt) {
return evt[0].type == "cell";
});
logEvents.should.have.length(1);
var msg = logEvents[0][0];
msg.should.have.property('level', helper.log().ERROR);
msg.should.have.property('id', 'n1');
msg.should.have.property('type', 'cell');
msg.should.have.property('msg', 'cell.errors.invalid-address: INVARID_ADDRESS');
done();
} catch (err) {
done(err);
}
});
});
});

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,204 @@
var should = require("should");
var helper = require("node-red-node-test-helper");
var bookNode = require("../book.js");
var sheetNode = require("../sheet.js");
var sheetToJsonNode = require("../sheet-to-json.js");
var fs = require('fs');
helper.init(require.resolve('node-red'));
describe('sheet-to-json Node', function () {
before(function (done) {
helper.startServer(done);
});
after(function (done) {
helper.stopServer(done);
});
afterEach(function () {
helper.unload();
});
it('should be loaded', function (done) {
var flow = [{ id: "n1", type: "sheet-to-json", name: "sheet-to-json1" }];
helper.load(sheetToJsonNode, flow, function () {
var n1 = helper.getNode("n1");
n1.should.have.property('name', 'sheet-to-json1');
done();
});
});
it('should convert a whole sheet object to an array of JSON objects', function (done) {
var flow = [
{ id: "n1", type: "book", name: "book1", wires: [["n2"]] },
{ id: "n2", type: "sheet", name: "sheet1", wires: [["n3"]], sheetName: "Sheet1" },
{ id: "n3", type: "sheet-to-json", name: "sheet-to-json1", wires: [["n4"]], raw: "false", range: "", header: "default", blankrows: false },
{ id: "n4", type: "helper" }
];
helper.load([bookNode, sheetNode, sheetToJsonNode], flow, function () {
var n4 = helper.getNode("n4");
n4.on("input", function (msg) {
msg.should.have.property('payload').eql([
{ col1: "1", col2: "2", col3: "3" },
{ col1: "4", col2: "5", col3: "6" }
]);
done();
});
var n1 = helper.getNode("n1");
var data = fs.readFileSync(__dirname + "/example.xlsx");
n1.receive({ payload: data });
});
});
it('should convert a whole sheet object to an array of JSON objects with raw values', function (done) {
var flow = [
{ id: "n1", type: "book", name: "book1", wires: [["n2"]] },
{ id: "n2", type: "sheet", name: "sheet1", wires: [["n3"]], sheetName: "Sheet1" },
{ id: "n3", type: "sheet-to-json", name: "sheet-to-json1", wires: [["n4"]], raw: "true", range: "", header: "default", blankrows: false },
{ id: "n4", type: "helper" }
];
helper.load([bookNode, sheetNode, sheetToJsonNode], flow, function () {
var n4 = helper.getNode("n4");
n4.on("input", function (msg) {
msg.should.have.property('payload').eql([
{ col1: 1, col2: 2, col3: 3 },
{ col1: 4, col2: 5, col3: 6 }
]);
done();
});
var n1 = helper.getNode("n1");
var data = fs.readFileSync(__dirname + "/example.xlsx");
n1.receive({ payload: data });
});
});
it('should convert the range of sheet specified in node config to an array of JSON objects with raw values', function (done) {
var flow = [
{ id: "n1", type: "book", name: "book1", wires: [["n2"]] },
{ id: "n2", type: "sheet", name: "sheet1", wires: [["n3"]], sheetName: "Sheet1" },
{ id: "n3", type: "sheet-to-json", name: "sheet-to-json1", wires: [["n4"]], raw: "true", range: "A1:B3", header: "default", blankrows: false },
{ id: "n4", type: "helper" }
];
helper.load([bookNode, sheetNode, sheetToJsonNode], flow, function () {
var n4 = helper.getNode("n4");
n4.on("input", function (msg) {
msg.should.have.property('payload').eql([
{ col1: 1, col2: 2 },
{ col1: 4, col2: 5 }
]);
msg.should.have.property('selectedRange', "A1:B3");
done();
});
var n1 = helper.getNode("n1");
var data = fs.readFileSync(__dirname + "/example.xlsx");
n1.receive({ payload: data });
});
});
it('should convert the range of sheet specified in msg object to an array of JSON objects with raw values', function (done) {
var flow = [
{ id: "n1", type: "book", name: "book1", wires: [["n2"]] },
{ id: "n2", type: "sheet", name: "sheet1", wires: [["n3"]], sheetName: "Sheet1" },
{ id: "n3", type: "sheet-to-json", name: "sheet-to-json1", wires: [["n4"]], raw: "true", range: "", header: "default", blankrows: false },
{ id: "n4", type: "helper" }
];
helper.load([bookNode, sheetNode, sheetToJsonNode], flow, function () {
var n4 = helper.getNode("n4");
n4.on("input", function (msg) {
msg.should.have.property('payload').eql([
{ col1: 1, col2: 2 },
{ col1: 4, col2: 5 }
]);
msg.should.have.property('selectedRange', "A1:B3");
msg.should.not.have.property('selectRange');
done();
});
var n1 = helper.getNode("n1");
var data = fs.readFileSync(__dirname + "/example.xlsx");
n1.receive({ payload: data, selectRange: "A1:B3" });
});
});
it('should convert the whole sheet obejct to an array of arrays', function (done) {
var flow = [
{ id: "n1", type: "book", name: "book1", wires: [["n2"]] },
{ id: "n2", type: "sheet", name: "sheet1", wires: [["n3"]], sheetName: "Sheet1" },
{ id: "n3", type: "sheet-to-json", name: "sheet-to-json1", wires: [["n4"]], raw: "true", range: "", header: "1", blankrows: false },
{ id: "n4", type: "helper" }
];
helper.load([bookNode, sheetNode, sheetToJsonNode], flow, function () {
var n4 = helper.getNode("n4");
n4.on("input", function (msg) {
msg.should.have.property('payload').eql([
["col1", "col2", "col3"],
[1, 2, 3],
[4, 5, 6]
]);
done();
});
var n1 = helper.getNode("n1");
var data = fs.readFileSync(__dirname + "/example.xlsx");
n1.receive({ payload: data });
});
});
it('should convert the whole sheet obejct to an array of row objects that keys are literal column labels', function (done) {
var flow = [
{ id: "n1", type: "book", name: "book1", wires: [["n2"]] },
{ id: "n2", type: "sheet", name: "sheet1", wires: [["n3"]], sheetName: "Sheet1" },
{ id: "n3", type: "sheet-to-json", name: "sheet-to-json1", wires: [["n4"]], raw: "true", range: "", header: "A", blankrows: false },
{ id: "n4", type: "helper" }
];
helper.load([bookNode, sheetNode, sheetToJsonNode], flow, function () {
var n4 = helper.getNode("n4");
n4.on("input", function (msg) {
msg.should.have.property('payload').eql([
{ A: "col1", B: "col2", C: "col3" },
{ A: 1, B: 2, C: 3 },
{ A: 4, B: 5, C: 6 }
]);
done();
});
var n1 = helper.getNode("n1");
var data = fs.readFileSync(__dirname + "/example.xlsx");
n1.receive({ payload: data });
});
});
it('should convert a whole CSV values to an array of JSON objects, with the exact strings written in CSV file', function (done) {
var flow = [
{ id: "n1", type: "book", name: "book1", wires: [["n2"]], raw: true },
{ id: "n2", type: "sheet", name: "sheet1", wires: [["n3"]], sheetName: "Sheet1" },
{ id: "n3", type: "sheet-to-json", name: "sheet-to-json1", wires: [["n4"]], raw: true, range: "", header: "default", blankrows: false },
{ id: "n4", type: "helper" }
];
helper.load([bookNode, sheetNode, sheetToJsonNode], flow, function () {
var n4 = helper.getNode("n4");
n4.on("input", function (msg) {
try {
msg.should.have.property('payload').eql([
{
Timestamp: "2020-07-09T20:00:07.000Z",
Humidity: "37.57400131",
Pressure: "992.5411987",
PM1: "16.66666667",
PM2_5: "21",
PM10: "21.66666667",
Temperature: "35.34999847",
DateTime: "1594324807.00",
}
]);
done();
} catch (e) {
done(e);
}
});
var n1 = helper.getNode("n1");
var data = fs.readFileSync(__dirname + "/time_issue.csv");
n1.receive({ payload: data });
});
});
});

View File

@@ -0,0 +1,70 @@
var should = require("should");
var helper = require("node-red-node-test-helper");
var bookNode = require("../book.js");
var sheetNode = require("../sheet.js");
var fs = require("fs");
helper.init(require.resolve('node-red'));
describe('sheet Node', function () {
before(function (done) {
helper.startServer(done);
});
after(function (done) {
helper.stopServer(done);
});
afterEach(function () {
helper.unload();
});
it('should be loaded', function (done) {
var flow = [{ id: "n1", type: "sheet", name: "sheet1" }];
helper.load(sheetNode, flow, function () {
var n1 = helper.getNode("n1");
n1.should.have.property('name', 'sheet1');
done();
});
});
it('should pick the sheet object specified in node config', function (done) {
var flow = [
{ id: "n1", type: "book", name: "book1", wires: [["n2"]] },
{ id: "n2", type: "sheet", name: "sheet1", wires: [["n3"]], sheetName: "Sheet1" },
{ id: "n3", type: "helper" }
];
helper.load([bookNode, sheetNode], flow, function () {
var n3 = helper.getNode("n3");
n3.on("input", function (msg) {
msg.should.have.propertyByPath('payload', '!ref').eql("A1:C3");
msg.should.have.property('selectedSheetName', "Sheet1");
done();
});
var n1 = helper.getNode("n1");
var data = fs.readFileSync(__dirname + "/example.xlsx");
n1.receive({ payload: data });
});
});
it('should pick the sheet object specified in msg object', function (done) {
var flow = [
{ id: "n1", type: "book", name: "book1", wires: [["n2"]] },
{ id: "n2", type: "sheet", name: "sheet1", wires: [["n3"]], sheetName: "" },
{ id: "n3", type: "helper" }
];
helper.load([bookNode, sheetNode], flow, function () {
var n3 = helper.getNode("n3");
n3.on("input", function (msg) {
msg.should.have.propertyByPath('payload', '!ref').eql("A1:C3");
msg.should.have.property('selectedSheetName', "Sheet1");
done();
});
var n1 = helper.getNode("n1");
var data = fs.readFileSync(__dirname + "/example.xlsx");
n1.receive({ payload: data, selectSheetName: "Sheet1" });
});
});
});

View File

@@ -0,0 +1,2 @@
Timestamp,Humidity,Pressure,PM1,PM2_5,PM10,Temperature,DateTime
2020-07-09T20:00:07.000Z,37.57400131,992.5411987,16.66666667,21,21.66666667,35.34999847,1594324807.00
1 Timestamp Humidity Pressure PM1 PM2_5 PM10 Temperature DateTime
2 2020-07-09T20:00:07.000Z 37.57400131 992.5411987 16.66666667 21 21.66666667 35.34999847 1594324807.00

Binary file not shown.