tle2文件转czml文件
This commit is contained in:
15
node_modules/node-xlsx/LICENSE.md
generated
vendored
Normal file
15
node_modules/node-xlsx/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
Copyright (c) 2012-2021 Olivier Louvignes
|
||||
|
||||
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.
|
||||
|
||||
Except where noted, this license applies to any and all software programs and associated documentation files created by
|
||||
the Original Author and distributed with the Software:
|
||||
|
||||
Inspired by SheetJS gist examples, Copyright (c) SheetJS.
|
||||
202
node_modules/node-xlsx/README.md
generated
vendored
Normal file
202
node_modules/node-xlsx/README.md
generated
vendored
Normal file
@@ -0,0 +1,202 @@
|
||||
<!-- markdownlint-disable no-inline-html -->
|
||||
|
||||
# node-xlsx
|
||||
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/package/node-xlsx">
|
||||
<img src="https://img.shields.io/npm/v/node-xlsx.svg?style=for-the-badge" alt="npm version" />
|
||||
</a>
|
||||
<a href="https://www.npmjs.com/package/node-xlsx">
|
||||
<img src="https://img.shields.io/npm/dt/node-xlsx.svg?style=for-the-badge" alt="npm total downloads" />
|
||||
</a>
|
||||
<a href="https://www.npmjs.com/package/node-xlsx">
|
||||
<img src="https://img.shields.io/npm/dm/node-xlsx.svg?style=for-the-badge" alt="npm monthly downloads" />
|
||||
</a>
|
||||
<a href="https://www.npmjs.com/package/node-xlsx">
|
||||
<img src="https://img.shields.io/npm/l/node-xlsx.svg?style=for-the-badge" alt="npm license" />
|
||||
</a>
|
||||
<a href="https://github.com/mgcrea/node-xlsx/actions/workflows/main.yml">
|
||||
<img src="https://img.shields.io/github/workflow/status/mgcrea/node-xlsx/main?style=for-the-badge" alt="github main workflow" />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
## Features
|
||||
|
||||
Straightforward excel file parser and builder.
|
||||
|
||||
- Relies on [SheetJS xlsx](https://github.com/SheetJS/sheetjs) module to parse/build excel sheets.
|
||||
- Built with [TypeScript](https://www.typescriptlang.org/) for static type checking with exported types along the
|
||||
library.
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
npm install node-xlsx --save
|
||||
```
|
||||
|
||||
## Quickstart
|
||||
|
||||
### Parse an xlsx file
|
||||
|
||||
```js
|
||||
import xlsx from 'node-xlsx';
|
||||
// Or var xlsx = require('node-xlsx').default;
|
||||
|
||||
// Parse a buffer
|
||||
const workSheetsFromBuffer = xlsx.parse(fs.readFileSync(`${__dirname}/myFile.xlsx`));
|
||||
// Parse a file
|
||||
const workSheetsFromFile = xlsx.parse(`${__dirname}/myFile.xlsx`);
|
||||
```
|
||||
|
||||
### Build an xlsx file
|
||||
|
||||
```js
|
||||
import xlsx from 'node-xlsx';
|
||||
// Or var xlsx = require('node-xlsx').default;
|
||||
|
||||
const data = [
|
||||
[1, 2, 3],
|
||||
[true, false, null, 'sheetjs'],
|
||||
['foo', 'bar', new Date('2014-02-19T14:30Z'), '0.3'],
|
||||
['baz', null, 'qux'],
|
||||
];
|
||||
var buffer = xlsx.build([{name: 'mySheetName', data: data}]); // Returns a buffer
|
||||
```
|
||||
|
||||
### Custom column width
|
||||
|
||||
```js
|
||||
import xlsx from 'node-xlsx';
|
||||
// Or var xlsx = require('node-xlsx').default;
|
||||
|
||||
const data = [
|
||||
[1, 2, 3],
|
||||
[true, false, null, 'sheetjs'],
|
||||
['foo', 'bar', new Date('2014-02-19T14:30Z'), '0.3'],
|
||||
['baz', null, 'qux'],
|
||||
];
|
||||
const sheetOptions = {'!cols': [{wch: 6}, {wch: 7}, {wch: 10}, {wch: 20}]};
|
||||
|
||||
var buffer = xlsx.build([{name: 'mySheetName', data: data}], {sheetOptions}); // Returns a buffer
|
||||
```
|
||||
|
||||
### Spanning multiple rows `A1:A4` in every sheets
|
||||
|
||||
```js
|
||||
import xlsx from 'node-xlsx';
|
||||
// Or var xlsx = require('node-xlsx').default;
|
||||
|
||||
const data = [
|
||||
[1, 2, 3],
|
||||
[true, false, null, 'sheetjs'],
|
||||
['foo', 'bar', new Date('2014-02-19T14:30Z'), '0.3'],
|
||||
['baz', null, 'qux'],
|
||||
];
|
||||
const range = {s: {c: 0, r: 0}, e: {c: 0, r: 3}}; // A1:A4
|
||||
const sheetOptions = {'!merges': [range]};
|
||||
|
||||
var buffer = xlsx.build([{name: 'mySheetName', data: data}], {sheetOptions}); // Returns a buffer
|
||||
```
|
||||
|
||||
### Spanning multiple rows `A1:A4` in second sheet
|
||||
|
||||
```js
|
||||
import xlsx from 'node-xlsx';
|
||||
// Or var xlsx = require('node-xlsx').default;
|
||||
|
||||
const dataSheet1 = [
|
||||
[1, 2, 3],
|
||||
[true, false, null, 'sheetjs'],
|
||||
['foo', 'bar', new Date('2014-02-19T14:30Z'), '0.3'],
|
||||
['baz', null, 'qux'],
|
||||
];
|
||||
const dataSheet2 = [
|
||||
[4, 5, 6],
|
||||
[7, 8, 9, 10],
|
||||
[11, 12, 13, 14],
|
||||
['baz', null, 'qux'],
|
||||
];
|
||||
const range = {s: {c: 0, r: 0}, e: {c: 0, r: 3}}; // A1:A4
|
||||
const sheetOptions = {'!merges': [range]};
|
||||
|
||||
var buffer = xlsx.build([
|
||||
{name: 'myFirstSheet', data: dataSheet1},
|
||||
{name: 'mySecondSheet', data: dataSheet2, options: sheetOptions},
|
||||
]); // Returns a buffer
|
||||
```
|
||||
|
||||
_Beware that if you try to merge several times the same cell, your xlsx file will be seen as corrupted._
|
||||
|
||||
- Using Primitive Object Notation Data values can also be specified in a non-abstracted representation.
|
||||
|
||||
Examples:
|
||||
|
||||
```js
|
||||
const rowAverage = [[{t: 'n', z: 10, f: '=AVERAGE(2:2)'}], [1, 2, 3]];
|
||||
var buffer = xlsx.build([{name: 'Average Formula', data: rowAverage}]);
|
||||
```
|
||||
|
||||
Refer to [xlsx](https://sheetjs.gitbooks.io) documentation for valid structure and values:
|
||||
|
||||
- [cell object]: (https://sheetjs.gitbooks.io/docs/#cell-object)
|
||||
- [data types]: (https://sheetjs.gitbooks.io/docs/#data-types)
|
||||
- [Format](https://sheetjs.gitbooks.io/docs/#number-formats)
|
||||
|
||||
### Troubleshooting
|
||||
|
||||
This library requires at least node.js v10. For legacy versions, you can use this workaround before using the lib.
|
||||
|
||||
```sh
|
||||
npm i --save object-assign
|
||||
```
|
||||
|
||||
```js
|
||||
Object.prototype.assign = require('object-assign');
|
||||
```
|
||||
|
||||
### Contributing
|
||||
|
||||
Please submit all pull requests the against master branch. If your unit test contains javascript patches or features,
|
||||
you should include relevant unit tests. Thanks!
|
||||
|
||||
### Available scripts
|
||||
|
||||
| **Script** | **Description** |
|
||||
| ------------- | ------------------------------ |
|
||||
| start | Alias of test:watch |
|
||||
| test | Run mocha unit tests |
|
||||
| test:watch | Run and watch mocha unit tests |
|
||||
| lint | Run eslint static tests |
|
||||
| compile | Compile the library |
|
||||
| compile:watch | Compile and watch the library |
|
||||
|
||||
## Authors
|
||||
|
||||
**Olivier Louvignes**
|
||||
|
||||
- http://olouv.com
|
||||
- http://github.com/mgcrea
|
||||
|
||||
## Copyright and license
|
||||
|
||||
[Apache License 2.0](https://spdx.org/licenses/Apache-2.0.html)
|
||||
|
||||
```
|
||||
Copyright (C) 2012-2014 Olivier Louvignes
|
||||
|
||||
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.
|
||||
|
||||
Except where noted, this license applies to any and all software programs and associated documentation files created by the Original Author and distributed with the Software:
|
||||
|
||||
Inspired by SheetJS gist examples, Copyright (c) SheetJS.
|
||||
```
|
||||
2
node_modules/node-xlsx/lib/bin/cli.d.ts
generated
vendored
Normal file
2
node_modules/node-xlsx/lib/bin/cli.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
#! /usr/bin/env node
|
||||
export {};
|
||||
34
node_modules/node-xlsx/lib/bin/cli.js
generated
vendored
Normal file
34
node_modules/node-xlsx/lib/bin/cli.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
#! /usr/bin/env node
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const promises_1 = require("fs/promises");
|
||||
const __1 = require("./..");
|
||||
const [action = 'build', ...args] = process.argv.slice(2);
|
||||
const readStdin = async (bufferSize) => {
|
||||
return new Promise((resolve) => {
|
||||
const buffers = [];
|
||||
process.stdin.on('readable', () => {
|
||||
const read = process.stdin.read();
|
||||
if (read) {
|
||||
buffers.push(read);
|
||||
}
|
||||
});
|
||||
process.stdin.on('end', () => {
|
||||
resolve(Buffer.concat(buffers, bufferSize));
|
||||
});
|
||||
});
|
||||
};
|
||||
const main = async () => {
|
||||
switch (action) {
|
||||
case 'build': {
|
||||
const stdin = JSON.parse((await readStdin()).toString('utf8'));
|
||||
const result = (0, __1.build)(stdin);
|
||||
await (0, promises_1.writeFile)(args[0] || `${process.cwd()}/out.xlsx`, result);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
console.log('Sorry, that is not something I know how to do.');
|
||||
}
|
||||
process.exit(0);
|
||||
};
|
||||
main();
|
||||
1
node_modules/node-xlsx/lib/helpers.d.ts
generated
vendored
Normal file
1
node_modules/node-xlsx/lib/helpers.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare const isString: (maybeString: unknown) => maybeString is string;
|
||||
5
node_modules/node-xlsx/lib/helpers.js
generated
vendored
Normal file
5
node_modules/node-xlsx/lib/helpers.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.isString = void 0;
|
||||
const isString = (maybeString) => typeof maybeString === 'string';
|
||||
exports.isString = isString;
|
||||
45
node_modules/node-xlsx/lib/index.d.ts
generated
vendored
Normal file
45
node_modules/node-xlsx/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
/// <reference types="node" />
|
||||
import { AOA2SheetOpts, AutoFilterInfo, ColInfo, ParsingOptions, ProtectInfo, Range, RowInfo, Sheet2JSONOpts, WritingOptions } from 'xlsx';
|
||||
export declare const parse: <T = any[]>(mixed: unknown, options?: Sheet2JSONOpts & ParsingOptions) => {
|
||||
name: string;
|
||||
data: T[];
|
||||
}[];
|
||||
export declare const parseMetadata: (mixed: unknown, options?: ParsingOptions) => {
|
||||
name: string;
|
||||
data: Range | null;
|
||||
}[];
|
||||
export type WorkSheetOptions = {
|
||||
/** Column Info */
|
||||
'!cols'?: ColInfo[];
|
||||
/** Row Info */
|
||||
'!rows'?: RowInfo[];
|
||||
/** Merge Ranges */
|
||||
'!merges'?: Range[];
|
||||
/** Worksheet Protection info */
|
||||
'!protect'?: ProtectInfo;
|
||||
/** AutoFilter info */
|
||||
'!autofilter'?: AutoFilterInfo;
|
||||
};
|
||||
export type WorkSheet<T = unknown> = {
|
||||
name: string;
|
||||
data: T[][];
|
||||
options: WorkSheetOptions;
|
||||
};
|
||||
export type BuildOptions = WorkSheetOptions & {
|
||||
parseOptions?: AOA2SheetOpts;
|
||||
writeOptions?: WritingOptions;
|
||||
sheetOptions?: WorkSheetOptions;
|
||||
};
|
||||
export declare const build: (worksheets: WorkSheet[], { parseOptions, writeOptions, sheetOptions, ...otherOptions }?: BuildOptions) => Buffer;
|
||||
declare const _default: {
|
||||
parse: <T = any[]>(mixed: unknown, options?: Sheet2JSONOpts & ParsingOptions) => {
|
||||
name: string;
|
||||
data: T[];
|
||||
}[];
|
||||
parseMetadata: (mixed: unknown, options?: ParsingOptions) => {
|
||||
name: string;
|
||||
data: Range | null;
|
||||
}[];
|
||||
build: (worksheets: WorkSheet<unknown>[], { parseOptions, writeOptions, sheetOptions, ...otherOptions }?: BuildOptions) => Buffer;
|
||||
};
|
||||
export default _default;
|
||||
59
node_modules/node-xlsx/lib/index.js
generated
vendored
Normal file
59
node_modules/node-xlsx/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.build = exports.parseMetadata = exports.parse = void 0;
|
||||
const xlsx_1 = require("xlsx");
|
||||
const helpers_1 = require("./helpers");
|
||||
const workbook_1 = require("./workbook");
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const parse = (mixed, options = {}) => {
|
||||
const { dateNF, header = 1, range, blankrows, defval, raw = true, rawNumbers, ...otherOptions } = options;
|
||||
const workBook = (0, helpers_1.isString)(mixed)
|
||||
? (0, xlsx_1.readFile)(mixed, { dateNF, raw, ...otherOptions })
|
||||
: (0, xlsx_1.read)(mixed, { dateNF, raw, ...otherOptions });
|
||||
return Object.keys(workBook.Sheets).map((name) => {
|
||||
const sheet = workBook.Sheets[name];
|
||||
return {
|
||||
name,
|
||||
data: xlsx_1.utils.sheet_to_json(sheet, {
|
||||
dateNF,
|
||||
header,
|
||||
range: typeof range === 'function' ? range(sheet) : range,
|
||||
blankrows,
|
||||
defval,
|
||||
raw,
|
||||
rawNumbers,
|
||||
}),
|
||||
};
|
||||
});
|
||||
};
|
||||
exports.parse = parse;
|
||||
const parseMetadata = (mixed, options = {}) => {
|
||||
const workBook = (0, helpers_1.isString)(mixed) ? (0, xlsx_1.readFile)(mixed, options) : (0, xlsx_1.read)(mixed, options);
|
||||
return Object.keys(workBook.Sheets).map((name) => {
|
||||
const sheet = workBook.Sheets[name];
|
||||
return { name, data: sheet['!ref'] ? xlsx_1.utils.decode_range(sheet['!ref']) : null };
|
||||
});
|
||||
};
|
||||
exports.parseMetadata = parseMetadata;
|
||||
const build = (worksheets, { parseOptions = {}, writeOptions = {}, sheetOptions = {}, ...otherOptions } = {}) => {
|
||||
const { bookType = 'xlsx', bookSST = false, type = 'buffer', ...otherWriteOptions } = writeOptions;
|
||||
const legacyOptions = Object.keys(otherOptions).filter((key) => {
|
||||
if (['!cols', '!rows', '!merges', '!protect', '!autofilter'].includes(key)) {
|
||||
console.debug(`Deprecated options['${key}'], please use options.sheetOptions['${key}'] instead.`);
|
||||
return true;
|
||||
}
|
||||
console.debug(`Unknown options['${key}'], please use options.parseOptions / options.writeOptions`);
|
||||
return false;
|
||||
});
|
||||
const workBook = worksheets.reduce((soFar, { name, data, options = {} }, index) => {
|
||||
const sheetName = name || `Sheet_${index}`;
|
||||
const sheetData = xlsx_1.utils.aoa_to_sheet(data, parseOptions);
|
||||
soFar.SheetNames.push(sheetName);
|
||||
soFar.Sheets[sheetName] = sheetData;
|
||||
Object.assign(soFar.Sheets[sheetName], legacyOptions, sheetOptions, options);
|
||||
return soFar;
|
||||
}, new workbook_1.WorkBook());
|
||||
return (0, xlsx_1.write)(workBook, { bookType, bookSST, type, ...otherWriteOptions });
|
||||
};
|
||||
exports.build = build;
|
||||
exports.default = { parse: exports.parse, parseMetadata: exports.parseMetadata, build: exports.build };
|
||||
5
node_modules/node-xlsx/lib/workbook.d.ts
generated
vendored
Normal file
5
node_modules/node-xlsx/lib/workbook.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import type { WorkBook as XLSXWorkBook, WorkSheet } from 'xlsx';
|
||||
export declare class WorkBook implements XLSXWorkBook {
|
||||
Sheets: Record<string, WorkSheet>;
|
||||
SheetNames: string[];
|
||||
}
|
||||
10
node_modules/node-xlsx/lib/workbook.js
generated
vendored
Normal file
10
node_modules/node-xlsx/lib/workbook.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.WorkBook = void 0;
|
||||
class WorkBook {
|
||||
constructor() {
|
||||
this.Sheets = {};
|
||||
this.SheetNames = [];
|
||||
}
|
||||
}
|
||||
exports.WorkBook = WorkBook;
|
||||
15
node_modules/node-xlsx/node_modules/.bin/xlsx
generated
vendored
Normal file
15
node_modules/node-xlsx/node_modules/.bin/xlsx
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
"$basedir/node" "$basedir/../../../xlsx/bin/xlsx.njs" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../../../xlsx/bin/xlsx.njs" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
||||
7
node_modules/node-xlsx/node_modules/.bin/xlsx.cmd
generated
vendored
Normal file
7
node_modules/node-xlsx/node_modules/.bin/xlsx.cmd
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
@IF EXIST "%~dp0\node.exe" (
|
||||
"%~dp0\node.exe" "%~dp0\..\..\..\xlsx\bin\xlsx.njs" %*
|
||||
) ELSE (
|
||||
@SETLOCAL
|
||||
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
node "%~dp0\..\..\..\xlsx\bin\xlsx.njs" %*
|
||||
)
|
||||
54
node_modules/node-xlsx/package.json
generated
vendored
Normal file
54
node_modules/node-xlsx/package.json
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"name": "node-xlsx",
|
||||
"author": "Olivier Louvignes <olivier@mg-crea.com>",
|
||||
"version": "0.23.0",
|
||||
"description": "NodeJS Excel files parser & builder",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"bin": {
|
||||
"node-xlsx": "./lib/bin/cli.js"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "npm run spec -- --watch",
|
||||
"build": "rimraf lib/*; tsc --build",
|
||||
"lint": "eslint src/ test/",
|
||||
"prettycheck": "prettier --check src/ test/",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"spec": "jest --runInBand",
|
||||
"test": "npm run lint && npm run prettycheck && npm run typecheck && npm run spec",
|
||||
"prepublishOnly": "npm run build"
|
||||
},
|
||||
"repository": "github:mgcrea/node-xlsx",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"xlsx": "https://cdn.sheetjs.com/xlsx-0.19.3/xlsx-0.19.3.tgz"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@jest/globals": "^29.5.0",
|
||||
"@tsconfig/node10": "^1.0.9",
|
||||
"@types/jest": "^29.5.1",
|
||||
"@types/sodium-native": "^2.3.5",
|
||||
"@typescript-eslint/eslint-plugin": "^5.59.7",
|
||||
"@typescript-eslint/parser": "^5.59.7",
|
||||
"eslint": "^8.41.0",
|
||||
"eslint-config-prettier": "^8.8.0",
|
||||
"eslint-plugin-jest": "^27.2.1",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"jest": "^29.5.0",
|
||||
"prettier": "^2.8.8",
|
||||
"rimraf": "^5.0.1",
|
||||
"ts-jest": "^29.1.0",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^5.0.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"keywords": [
|
||||
"excel",
|
||||
"parser",
|
||||
"builder",
|
||||
"xlsx",
|
||||
"xls"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user