@loaders.gl/excel 4.0.0-alpha.9 → 4.0.0-beta.1

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.
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports._typecheckLoader = exports.ExcelLoader = void 0;
7
- var VERSION = typeof "4.0.0-alpha.9" !== 'undefined' ? "4.0.0-alpha.9" : 'latest';
6
+ exports.ExcelLoader = void 0;
7
+ var VERSION = typeof "4.0.0-beta.1" !== 'undefined' ? "4.0.0-beta.1" : 'latest';
8
8
  var DEFAULT_EXCEL_LOADER_OPTIONS = {
9
9
  excel: {
10
10
  shape: 'object-row-table',
@@ -24,6 +24,4 @@ var ExcelLoader = {
24
24
  options: DEFAULT_EXCEL_LOADER_OPTIONS
25
25
  };
26
26
  exports.ExcelLoader = ExcelLoader;
27
- var _typecheckLoader = ExcelLoader;
28
- exports._typecheckLoader = _typecheckLoader;
29
27
  //# sourceMappingURL=excel-loader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"excel-loader.js","names":["VERSION","DEFAULT_EXCEL_LOADER_OPTIONS","excel","shape","sheet","undefined","ExcelLoader","name","id","module","version","worker","extensions","mimeTypes","category","binary","options","exports","_typecheckLoader"],"sources":["../../src/excel-loader.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {Loader, LoaderOptions} from '@loaders.gl/loader-utils';\nimport type {ObjectRowTable} from '@loaders.gl/schema';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type ExcelLoaderOptions = LoaderOptions & {\n excel?: {\n shape: /* 'array-row-table' | */ 'object-row-table';\n sheet?: string; // Load default Sheet\n };\n};\n\nconst DEFAULT_EXCEL_LOADER_OPTIONS: ExcelLoaderOptions = {\n excel: {\n shape: 'object-row-table',\n sheet: undefined // Load default Sheet\n }\n};\n\n/**\n * Worker Loader for Excel files\n */\nexport const ExcelLoader: Loader<ObjectRowTable, never, ExcelLoaderOptions> = {\n name: 'Excel',\n id: 'excel',\n module: 'excel',\n version: VERSION,\n worker: true,\n extensions: ['xls', 'xlsb', 'xlsm', 'xlsx'],\n mimeTypes: [\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n 'application/vnd.ms-excel'\n ],\n category: 'table',\n binary: true,\n options: DEFAULT_EXCEL_LOADER_OPTIONS\n};\n\nexport const _typecheckLoader: Loader = ExcelLoader;\n"],"mappings":";;;;;;AAOA,IAAMA,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiB,QAAQ;AAS3E,IAAMC,4BAAgD,GAAG;EACvDC,KAAK,EAAE;IACLC,KAAK,EAAE,kBAAkB;IACzBC,KAAK,EAAEC;EACT;AACF,CAAC;AAKM,IAAMC,WAA8D,GAAG;EAC5EC,IAAI,EAAE,OAAO;EACbC,EAAE,EAAE,OAAO;EACXC,MAAM,EAAE,OAAO;EACfC,OAAO,EAAEV,OAAO;EAChBW,MAAM,EAAE,IAAI;EACZC,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;EAC3CC,SAAS,EAAE,CACT,mEAAmE,EACnE,0BAA0B,CAC3B;EACDC,QAAQ,EAAE,OAAO;EACjBC,MAAM,EAAE,IAAI;EACZC,OAAO,EAAEf;AACX,CAAC;AAACgB,OAAA,CAAAX,WAAA,GAAAA,WAAA;AAEK,IAAMY,gBAAwB,GAAGZ,WAAW;AAACW,OAAA,CAAAC,gBAAA,GAAAA,gBAAA"}
1
+ {"version":3,"file":"excel-loader.js","names":["VERSION","DEFAULT_EXCEL_LOADER_OPTIONS","excel","shape","sheet","undefined","ExcelLoader","name","id","module","version","worker","extensions","mimeTypes","category","binary","options","exports"],"sources":["../../src/excel-loader.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {Loader, LoaderOptions} from '@loaders.gl/loader-utils';\nimport type {ObjectRowTable} from '@loaders.gl/schema';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type ExcelLoaderOptions = LoaderOptions & {\n excel?: {\n shape: /* 'array-row-table' | */ 'object-row-table';\n sheet?: string; // Load default Sheet\n };\n};\n\nconst DEFAULT_EXCEL_LOADER_OPTIONS: ExcelLoaderOptions = {\n excel: {\n shape: 'object-row-table',\n sheet: undefined // Load default Sheet\n }\n};\n\n/**\n * Worker Loader for Excel files\n */\nexport const ExcelLoader: Loader<ObjectRowTable, never, ExcelLoaderOptions> = {\n name: 'Excel',\n id: 'excel',\n module: 'excel',\n version: VERSION,\n worker: true,\n extensions: ['xls', 'xlsb', 'xlsm', 'xlsx'],\n mimeTypes: [\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n 'application/vnd.ms-excel'\n ],\n category: 'table',\n binary: true,\n options: DEFAULT_EXCEL_LOADER_OPTIONS\n};\n"],"mappings":";;;;;;AAOA,IAAMA,OAAO,GAAG,qBAAkB,KAAK,WAAW,oBAAiB,QAAQ;AAS3E,IAAMC,4BAAgD,GAAG;EACvDC,KAAK,EAAE;IACLC,KAAK,EAAE,kBAAkB;IACzBC,KAAK,EAAEC;EACT;AACF,CAAC;AAKM,IAAMC,WAA8D,GAAG;EAC5EC,IAAI,EAAE,OAAO;EACbC,EAAE,EAAE,OAAO;EACXC,MAAM,EAAE,OAAO;EACfC,OAAO,EAAEV,OAAO;EAChBW,MAAM,EAAE,IAAI;EACZC,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;EAC3CC,SAAS,EAAE,CACT,mEAAmE,EACnE,0BAA0B,CAC3B;EACDC,QAAQ,EAAE,OAAO;EACjBC,MAAM,EAAE,IAAI;EACZC,OAAO,EAAEf;AACX,CAAC;AAACgB,OAAA,CAAAX,WAAA,GAAAA,WAAA"}
@@ -1,4 +1,4 @@
1
- const VERSION = typeof "4.0.0-alpha.9" !== 'undefined' ? "4.0.0-alpha.9" : 'latest';
1
+ const VERSION = typeof "4.0.0-beta.1" !== 'undefined' ? "4.0.0-beta.1" : 'latest';
2
2
  const DEFAULT_EXCEL_LOADER_OPTIONS = {
3
3
  excel: {
4
4
  shape: 'object-row-table',
@@ -17,5 +17,4 @@ export const ExcelLoader = {
17
17
  binary: true,
18
18
  options: DEFAULT_EXCEL_LOADER_OPTIONS
19
19
  };
20
- export const _typecheckLoader = ExcelLoader;
21
20
  //# sourceMappingURL=excel-loader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"excel-loader.js","names":["VERSION","DEFAULT_EXCEL_LOADER_OPTIONS","excel","shape","sheet","undefined","ExcelLoader","name","id","module","version","worker","extensions","mimeTypes","category","binary","options","_typecheckLoader"],"sources":["../../src/excel-loader.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {Loader, LoaderOptions} from '@loaders.gl/loader-utils';\nimport type {ObjectRowTable} from '@loaders.gl/schema';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type ExcelLoaderOptions = LoaderOptions & {\n excel?: {\n shape: /* 'array-row-table' | */ 'object-row-table';\n sheet?: string; // Load default Sheet\n };\n};\n\nconst DEFAULT_EXCEL_LOADER_OPTIONS: ExcelLoaderOptions = {\n excel: {\n shape: 'object-row-table',\n sheet: undefined // Load default Sheet\n }\n};\n\n/**\n * Worker Loader for Excel files\n */\nexport const ExcelLoader: Loader<ObjectRowTable, never, ExcelLoaderOptions> = {\n name: 'Excel',\n id: 'excel',\n module: 'excel',\n version: VERSION,\n worker: true,\n extensions: ['xls', 'xlsb', 'xlsm', 'xlsx'],\n mimeTypes: [\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n 'application/vnd.ms-excel'\n ],\n category: 'table',\n binary: true,\n options: DEFAULT_EXCEL_LOADER_OPTIONS\n};\n\nexport const _typecheckLoader: Loader = ExcelLoader;\n"],"mappings":"AAOA,MAAMA,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiB,QAAQ;AAS3E,MAAMC,4BAAgD,GAAG;EACvDC,KAAK,EAAE;IACLC,KAAK,EAAE,kBAAkB;IACzBC,KAAK,EAAEC;EACT;AACF,CAAC;AAKD,OAAO,MAAMC,WAA8D,GAAG;EAC5EC,IAAI,EAAE,OAAO;EACbC,EAAE,EAAE,OAAO;EACXC,MAAM,EAAE,OAAO;EACfC,OAAO,EAAEV,OAAO;EAChBW,MAAM,EAAE,IAAI;EACZC,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;EAC3CC,SAAS,EAAE,CACT,mEAAmE,EACnE,0BAA0B,CAC3B;EACDC,QAAQ,EAAE,OAAO;EACjBC,MAAM,EAAE,IAAI;EACZC,OAAO,EAAEf;AACX,CAAC;AAED,OAAO,MAAMgB,gBAAwB,GAAGX,WAAW"}
1
+ {"version":3,"file":"excel-loader.js","names":["VERSION","DEFAULT_EXCEL_LOADER_OPTIONS","excel","shape","sheet","undefined","ExcelLoader","name","id","module","version","worker","extensions","mimeTypes","category","binary","options"],"sources":["../../src/excel-loader.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {Loader, LoaderOptions} from '@loaders.gl/loader-utils';\nimport type {ObjectRowTable} from '@loaders.gl/schema';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type ExcelLoaderOptions = LoaderOptions & {\n excel?: {\n shape: /* 'array-row-table' | */ 'object-row-table';\n sheet?: string; // Load default Sheet\n };\n};\n\nconst DEFAULT_EXCEL_LOADER_OPTIONS: ExcelLoaderOptions = {\n excel: {\n shape: 'object-row-table',\n sheet: undefined // Load default Sheet\n }\n};\n\n/**\n * Worker Loader for Excel files\n */\nexport const ExcelLoader: Loader<ObjectRowTable, never, ExcelLoaderOptions> = {\n name: 'Excel',\n id: 'excel',\n module: 'excel',\n version: VERSION,\n worker: true,\n extensions: ['xls', 'xlsb', 'xlsm', 'xlsx'],\n mimeTypes: [\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n 'application/vnd.ms-excel'\n ],\n category: 'table',\n binary: true,\n options: DEFAULT_EXCEL_LOADER_OPTIONS\n};\n"],"mappings":"AAOA,MAAMA,OAAO,GAAG,qBAAkB,KAAK,WAAW,oBAAiB,QAAQ;AAS3E,MAAMC,4BAAgD,GAAG;EACvDC,KAAK,EAAE;IACLC,KAAK,EAAE,kBAAkB;IACzBC,KAAK,EAAEC;EACT;AACF,CAAC;AAKD,OAAO,MAAMC,WAA8D,GAAG;EAC5EC,IAAI,EAAE,OAAO;EACbC,EAAE,EAAE,OAAO;EACXC,MAAM,EAAE,OAAO;EACfC,OAAO,EAAEV,OAAO;EAChBW,MAAM,EAAE,IAAI;EACZC,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;EAC3CC,SAAS,EAAE,CACT,mEAAmE,EACnE,0BAA0B,CAC3B;EACDC,QAAQ,EAAE,OAAO;EACjBC,MAAM,EAAE,IAAI;EACZC,OAAO,EAAEf;AACX,CAAC"}
@@ -10,5 +10,4 @@ export type ExcelLoaderOptions = LoaderOptions & {
10
10
  * Worker Loader for Excel files
11
11
  */
12
12
  export declare const ExcelLoader: Loader<ObjectRowTable, never, ExcelLoaderOptions>;
13
- export declare const _typecheckLoader: Loader;
14
13
  //# sourceMappingURL=excel-loader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"excel-loader.d.ts","sourceRoot":"","sources":["../src/excel-loader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAMvD,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG;IAC/C,KAAK,CAAC,EAAE;QACN,KAAK,EAA4B,kBAAkB,CAAC;QACpD,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAAC;AASF;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,cAAc,EAAE,KAAK,EAAE,kBAAkB,CAczE,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,MAAoB,CAAC"}
1
+ {"version":3,"file":"excel-loader.d.ts","sourceRoot":"","sources":["../src/excel-loader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAMvD,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG;IAC/C,KAAK,CAAC,EAAE;QACN,KAAK,EAA4B,kBAAkB,CAAC;QACpD,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAAC;AASF;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,cAAc,EAAE,KAAK,EAAE,kBAAkB,CAczE,CAAC"}
@@ -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) {
@@ -35895,7 +35895,7 @@
35895
35895
  options,
35896
35896
  context: {
35897
35897
  ...context,
35898
- parse: parseOnMainThread
35898
+ _parse: parseOnMainThread
35899
35899
  }
35900
35900
  });
35901
35901
  WorkerBody.postMessage("done", { result });
@@ -35908,7 +35908,7 @@
35908
35908
  }
35909
35909
  };
35910
35910
  }
35911
- function parseOnMainThread(arrayBuffer, options) {
35911
+ function parseOnMainThread(arrayBuffer, loader, options, context) {
35912
35912
  return new Promise((resolve, reject) => {
35913
35913
  const id = requestId++;
35914
35914
  const onMessage = (type, payload2) => {
@@ -35932,7 +35932,12 @@
35932
35932
  WorkerBody.postMessage("process", payload);
35933
35933
  });
35934
35934
  }
35935
- async function parseData({ loader, arrayBuffer, options, context }) {
35935
+ async function parseData({
35936
+ loader,
35937
+ arrayBuffer,
35938
+ options,
35939
+ context
35940
+ }) {
35936
35941
  let data;
35937
35942
  let parser;
35938
35943
  if (loader.parseSync || loader.parse) {
@@ -35954,7 +35959,7 @@
35954
35959
  }
35955
35960
 
35956
35961
  // src/excel-loader.ts
35957
- var VERSION = true ? "4.0.0-alpha.9" : "latest";
35962
+ var VERSION = true ? "4.0.0-beta.1" : "latest";
35958
35963
  var DEFAULT_EXCEL_LOADER_OPTIONS = {
35959
35964
  excel: {
35960
35965
  shape: "object-row-table",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/excel",
3
- "version": "4.0.0-alpha.9",
3
+ "version": "4.0.0-beta.1",
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": "4.0.0-alpha.9",
39
- "@loaders.gl/schema": "4.0.0-alpha.9",
38
+ "@loaders.gl/loader-utils": "4.0.0-beta.1",
39
+ "@loaders.gl/schema": "4.0.0-beta.1",
40
40
  "xlsx": "^0.17.0"
41
41
  },
42
- "gitHead": "03ff81ab468f20f3bddeec787aa88d477a7e1c72"
42
+ "gitHead": "35c625e67132b0784e597d9ddabae8aefea29ff2"
43
43
  }
@@ -39,5 +39,3 @@ export const ExcelLoader: Loader<ObjectRowTable, never, ExcelLoaderOptions> = {
39
39
  binary: true,
40
40
  options: DEFAULT_EXCEL_LOADER_OPTIONS
41
41
  };
42
-
43
- export const _typecheckLoader: Loader = ExcelLoader;
package/dist/bundle.js DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
- // @ts-nocheck
3
- const moduleExports = require('./index');
4
- globalThis.loaders = globalThis.loaders || {};
5
- module.exports = Object.assign(globalThis.loaders, moduleExports);
@@ -1,32 +0,0 @@
1
- "use strict";
2
- // loaders.gl, MIT license
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports._typecheckLoader = exports.ExcelLoader = void 0;
5
- // __VERSION__ is injected by babel-plugin-version-inline
6
- // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
- const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
8
- const DEFAULT_EXCEL_LOADER_OPTIONS = {
9
- excel: {
10
- shape: 'object-row-table',
11
- sheet: undefined // Load default Sheet
12
- }
13
- };
14
- /**
15
- * Worker Loader for Excel files
16
- */
17
- exports.ExcelLoader = {
18
- name: 'Excel',
19
- id: 'excel',
20
- module: 'excel',
21
- version: VERSION,
22
- worker: true,
23
- extensions: ['xls', 'xlsb', 'xlsm', 'xlsx'],
24
- mimeTypes: [
25
- 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
26
- 'application/vnd.ms-excel'
27
- ],
28
- category: 'table',
29
- binary: true,
30
- options: DEFAULT_EXCEL_LOADER_OPTIONS
31
- };
32
- exports._typecheckLoader = exports.ExcelLoader;
package/dist/index.js DELETED
@@ -1,17 +0,0 @@
1
- "use strict";
2
- // loaders.gl, MIT license
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.ExcelLoader = exports.ExcelWorkerLoader = void 0;
5
- const excel_loader_1 = require("./excel-loader");
6
- Object.defineProperty(exports, "ExcelWorkerLoader", { enumerable: true, get: function () { return excel_loader_1.ExcelLoader; } });
7
- const parse_excel_1 = require("./lib/parse-excel");
8
- /**
9
- * Loader for Excel files
10
- */
11
- exports.ExcelLoader = {
12
- ...excel_loader_1.ExcelLoader,
13
- async parse(arrayBuffer, options) {
14
- const data = (0, parse_excel_1.parseExcel)(arrayBuffer, options);
15
- return { shape: 'object-row-table', data };
16
- }
17
- };
@@ -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
- */
@@ -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
- 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;
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const loader_utils_1 = require("@loaders.gl/loader-utils");
4
- const index_1 = require("../index");
5
- (0, loader_utils_1.createLoaderWorker)(index_1.ExcelLoader);