@loaders.gl/excel 3.4.11 → 3.4.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es5/excel-loader.js +1 -1
- package/dist/esm/excel-loader.js +1 -1
- package/dist/excel-worker.js +13 -13
- package/package.json +4 -4
- package/dist/bundle.js +0 -5
- package/dist/excel-loader.js +0 -31
- package/dist/index.js +0 -14
- package/dist/lib/encode-excel.js +0 -81
- package/dist/lib/parse-excel.js +0 -47
- package/dist/workers/excel-worker.js +0 -5
package/dist/es5/excel-loader.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports._typecheckLoader = exports.ExcelLoader = void 0;
|
|
7
|
-
var VERSION = typeof "3.4.
|
|
7
|
+
var VERSION = typeof "3.4.13" !== 'undefined' ? "3.4.13" : 'latest';
|
|
8
8
|
var DEFAULT_EXCEL_LOADER_OPTIONS = {
|
|
9
9
|
excel: {
|
|
10
10
|
shape: 'object-row-table',
|
package/dist/esm/excel-loader.js
CHANGED
package/dist/excel-worker.js
CHANGED
|
@@ -28,18 +28,6 @@
|
|
|
28
28
|
return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
// (disabled):fs
|
|
32
|
-
var require_fs = __commonJS({
|
|
33
|
-
"(disabled):fs"() {
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// (disabled):stream
|
|
38
|
-
var require_stream = __commonJS({
|
|
39
|
-
"(disabled):stream"() {
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
|
|
43
31
|
// ../../node_modules/xlsx/dist/cpexcel.js
|
|
44
32
|
var require_cpexcel = __commonJS({
|
|
45
33
|
"../../node_modules/xlsx/dist/cpexcel.js"(exports, module) {
|
|
@@ -3864,6 +3852,12 @@
|
|
|
3864
3852
|
}
|
|
3865
3853
|
});
|
|
3866
3854
|
|
|
3855
|
+
// (disabled):fs
|
|
3856
|
+
var require_fs = __commonJS({
|
|
3857
|
+
"(disabled):fs"() {
|
|
3858
|
+
}
|
|
3859
|
+
});
|
|
3860
|
+
|
|
3867
3861
|
// ../../node_modules/xlsx/jszip.js
|
|
3868
3862
|
var require_jszip = __commonJS({
|
|
3869
3863
|
"../../node_modules/xlsx/jszip.js"(exports, module) {
|
|
@@ -9511,6 +9505,12 @@
|
|
|
9511
9505
|
}
|
|
9512
9506
|
});
|
|
9513
9507
|
|
|
9508
|
+
// (disabled):stream
|
|
9509
|
+
var require_stream = __commonJS({
|
|
9510
|
+
"(disabled):stream"() {
|
|
9511
|
+
}
|
|
9512
|
+
});
|
|
9513
|
+
|
|
9514
9514
|
// ../../node_modules/xlsx/xlsx.js
|
|
9515
9515
|
var require_xlsx = __commonJS({
|
|
9516
9516
|
"../../node_modules/xlsx/xlsx.js"(exports, module) {
|
|
@@ -35954,7 +35954,7 @@
|
|
|
35954
35954
|
}
|
|
35955
35955
|
|
|
35956
35956
|
// src/excel-loader.ts
|
|
35957
|
-
var VERSION = true ? "3.4.
|
|
35957
|
+
var VERSION = true ? "3.4.13" : "latest";
|
|
35958
35958
|
var DEFAULT_EXCEL_LOADER_OPTIONS = {
|
|
35959
35959
|
excel: {
|
|
35960
35960
|
shape: "object-row-table",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/excel",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.13",
|
|
4
4
|
"description": "Framework-independent loader for Excel files",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"build-worker": "esbuild src/workers/excel-worker.ts --bundle --outfile=dist/excel-worker.js --define:__VERSION__=\\\"$npm_package_version\\\""
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@loaders.gl/loader-utils": "3.4.
|
|
39
|
-
"@loaders.gl/schema": "3.4.
|
|
38
|
+
"@loaders.gl/loader-utils": "3.4.13",
|
|
39
|
+
"@loaders.gl/schema": "3.4.13",
|
|
40
40
|
"xlsx": "^0.17.0"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "be8849c02972ce541e01720d29b976f830d6af92"
|
|
43
43
|
}
|
package/dist/bundle.js
DELETED
package/dist/excel-loader.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._typecheckLoader = exports.ExcelLoader = void 0;
|
|
4
|
-
// __VERSION__ is injected by babel-plugin-version-inline
|
|
5
|
-
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
6
|
-
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
7
|
-
const DEFAULT_EXCEL_LOADER_OPTIONS = {
|
|
8
|
-
excel: {
|
|
9
|
-
shape: 'object-row-table',
|
|
10
|
-
sheet: undefined // Load default Sheet
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Worker Loader for Excel files
|
|
15
|
-
*/
|
|
16
|
-
exports.ExcelLoader = {
|
|
17
|
-
name: 'Excel',
|
|
18
|
-
id: 'excel',
|
|
19
|
-
module: 'excel',
|
|
20
|
-
version: VERSION,
|
|
21
|
-
worker: true,
|
|
22
|
-
extensions: ['xls', 'xlsb', 'xlsm', 'xlsx'],
|
|
23
|
-
mimeTypes: [
|
|
24
|
-
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
25
|
-
'application/vnd.ms-excel'
|
|
26
|
-
],
|
|
27
|
-
category: 'table',
|
|
28
|
-
binary: true,
|
|
29
|
-
options: DEFAULT_EXCEL_LOADER_OPTIONS
|
|
30
|
-
};
|
|
31
|
-
exports._typecheckLoader = exports.ExcelLoader;
|
package/dist/index.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._typecheckLoader = exports.ExcelLoader = exports.ExcelWorkerLoader = void 0;
|
|
4
|
-
const excel_loader_1 = require("./excel-loader");
|
|
5
|
-
Object.defineProperty(exports, "ExcelWorkerLoader", { enumerable: true, get: function () { return excel_loader_1.ExcelLoader; } });
|
|
6
|
-
const parse_excel_1 = require("./lib/parse-excel");
|
|
7
|
-
/**
|
|
8
|
-
* Loader for Excel files
|
|
9
|
-
*/
|
|
10
|
-
exports.ExcelLoader = {
|
|
11
|
-
...excel_loader_1.ExcelLoader,
|
|
12
|
-
parse: (arrayBuffer, options) => (0, parse_excel_1.parseExcel)(arrayBuffer, options)
|
|
13
|
-
};
|
|
14
|
-
exports._typecheckLoader = exports.ExcelLoader;
|
package/dist/lib/encode-excel.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import * as xlsx from 'xlsx';
|
|
3
|
-
/**
|
|
4
|
-
* Saves JSON data in Excel format for html, ods, xml, xlsb and xlsx file types.
|
|
5
|
-
* @param filePath Local data file path.
|
|
6
|
-
* @param fileData Raw data to save.
|
|
7
|
-
* @param tableName Table name for data files with multiple tables support.
|
|
8
|
-
* @param showData Show saved data callback.
|
|
9
|
-
*
|
|
10
|
-
public saveData(filePath: string, fileData: any, tableName: string, showData?: Function): void {
|
|
11
|
-
const fileType: string = filePath.substr(filePath.lastIndexOf('.'));
|
|
12
|
-
fileData = this.jsonToExcelData(fileData, fileType, tableName);
|
|
13
|
-
if ( fileData.length > 0) {
|
|
14
|
-
// TODO: change this to async later
|
|
15
|
-
fs.writeFile(filePath, fileData, (error) => showData(error));
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Converts JSON data to Excel data formats.
|
|
21
|
-
* @param jsonData Json data to convert.
|
|
22
|
-
* @param bookType Excel data file/book type.
|
|
23
|
-
*
|
|
24
|
-
private jsonToExcelData(jsonData: any, fileType: string, tableName: string): any {
|
|
25
|
-
console.debug('jsonToExcelData(): creating excel data:', fileType);
|
|
26
|
-
|
|
27
|
-
// create new workbook
|
|
28
|
-
const workbook = xlsx.utils.book_new();
|
|
29
|
-
|
|
30
|
-
// convert json data to worksheet format
|
|
31
|
-
const worksheet = xlsx.utils.json_to_sheet(jsonData, {
|
|
32
|
-
//header: JSON.parse(this._viewConfig.columns)
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
// append worksheet to workbook
|
|
36
|
-
xlsx.utils.book_append_sheet(workbook, worksheet, tableName);
|
|
37
|
-
|
|
38
|
-
// get text data string or binary spreadsheet data buffer
|
|
39
|
-
let data: any = '';
|
|
40
|
-
if (fileType === 'html' || fileType === 'xml') {
|
|
41
|
-
data = xlsx.write(workbook, {
|
|
42
|
-
type: 'string',
|
|
43
|
-
compression: false,
|
|
44
|
-
bookType: getBookType(fileType)
|
|
45
|
-
});
|
|
46
|
-
} else {
|
|
47
|
-
data = xlsx.write(workbook, {
|
|
48
|
-
type: 'buffer',
|
|
49
|
-
compression: true, // use zip compression for zip-based formats
|
|
50
|
-
bookType: getBookType(fileType)
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
return data;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Converts file type to Excel book type.
|
|
61
|
-
* @param {string} fileType File type: .html, .ods, .xml, .xlsb, .xlsx, etc.
|
|
62
|
-
* @returns {xlsx.BookType}
|
|
63
|
-
*
|
|
64
|
-
function getBookType(fileType) {
|
|
65
|
-
// TODO: must be a better way to do this string to type conversion :)
|
|
66
|
-
switch (fileType) {
|
|
67
|
-
case '.html':
|
|
68
|
-
return 'html';
|
|
69
|
-
case '.ods':
|
|
70
|
-
return 'ods';
|
|
71
|
-
case '.xml':
|
|
72
|
-
return 'xlml';
|
|
73
|
-
case '.xlsb':
|
|
74
|
-
return 'xlsb';
|
|
75
|
-
case '.xlsx':
|
|
76
|
-
return 'xlsx';
|
|
77
|
-
default:
|
|
78
|
-
return 'xlsb';
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
*/
|
package/dist/lib/parse-excel.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseExcel = void 0;
|
|
4
|
-
const xlsx_1 = require("xlsx");
|
|
5
|
-
// import {convertToArrayRow} from '@loaders.gl/schema';
|
|
6
|
-
// local table names cache with dataUrl/tableNames array key/values
|
|
7
|
-
const dataTableNamesMap = {};
|
|
8
|
-
/**
|
|
9
|
-
* Gets local or remote Excel file data.
|
|
10
|
-
* @param arrayBuffer Loaded data
|
|
11
|
-
* @param options Data parse options.
|
|
12
|
-
*/
|
|
13
|
-
async function parseExcel(arrayBuffer, options) {
|
|
14
|
-
const dataUrl = 'dummy';
|
|
15
|
-
// const dataFileType: string = dataUrl.substr(dataUrl.lastIndexOf('.')); // file extension
|
|
16
|
-
// create Excel 'workbook'
|
|
17
|
-
const workbook = (0, xlsx_1.read)(arrayBuffer, {
|
|
18
|
-
type: 'array'
|
|
19
|
-
// cellDates: true
|
|
20
|
-
});
|
|
21
|
-
// load data sheets
|
|
22
|
-
let dataRows = [];
|
|
23
|
-
dataTableNamesMap[dataUrl] = [];
|
|
24
|
-
if (workbook.SheetNames.length > 0) {
|
|
25
|
-
if (workbook.SheetNames.length > 1) {
|
|
26
|
-
// cache sheet names
|
|
27
|
-
dataTableNamesMap[dataUrl] = workbook.SheetNames;
|
|
28
|
-
// eslint-ignore-next-line
|
|
29
|
-
// console.debug(`getData(): file: sheetNames:`, workbook.SheetNames);
|
|
30
|
-
}
|
|
31
|
-
// determine spreadsheet to load
|
|
32
|
-
let sheetName = workbook.SheetNames[0];
|
|
33
|
-
if (options?.excel?.sheet && workbook.SheetNames.indexOf(options?.excel?.sheet) >= 0) {
|
|
34
|
-
// reset to requested table name
|
|
35
|
-
sheetName = options?.excel?.sheet;
|
|
36
|
-
}
|
|
37
|
-
// get worksheet data row objects array
|
|
38
|
-
const worksheet = workbook.Sheets[sheetName];
|
|
39
|
-
dataRows = xlsx_1.utils.sheet_to_json(worksheet);
|
|
40
|
-
// const headers = dataRows.length ? Object.keys(dataRows[0]) : [];
|
|
41
|
-
// if (options?.excel?.type === 'array-row-table') {
|
|
42
|
-
// dataRows = dataRows.map(row => convertToArrayRow(row, headers))
|
|
43
|
-
// }
|
|
44
|
-
}
|
|
45
|
-
return dataRows;
|
|
46
|
-
}
|
|
47
|
-
exports.parseExcel = parseExcel;
|