@microsoft/connected-workbooks 1.0.0 → 2.1.24-beta

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/README.md CHANGED
@@ -1,84 +1,178 @@
1
1
  # Connected Workbooks
2
+ [![Build Status](https://obilshield.visualstudio.com/ConnectedWorkbooks/_apis/build/status/microsoft.connected-workbooks?branchName=main)](https://obilshield.visualstudio.com/ConnectedWorkbooks/_build/latest?definitionId=14&branchName=main)
3
+ [![License](https://img.shields.io/github/license/microsoft/connected-workbooks)](https://github.com/microsoft/connected-workbooks/blob/master/LICENSE)
4
+ [![Snyk Vulnerabilities](https://img.shields.io/snyk/vulnerabilities/github/microsoft/connected-workbooks)](https://snyk.io/test/github/microsoft/connected-workbooks)
2
5
 
3
- ## Using this project
6
+ A pure JS library, Microsoft backed, that provides xlsx workbook generation capabilities, allowing for:
7
+ 1. Fundemental **"Export to Excel"** capabilities for tabular data (landing in a table in Excel).
8
+ 2. Advanced capabilities of **"Export a Power Query connected workbook"**:
9
+ - Can refresh your data on open and/or on demand.
10
+ - Allows for initial data population.
11
+ - Supports more advanced scenarios where you provide branded/custom workbooks, and load your data into PivotTables or PivotCharts.
4
12
 
5
- Use this project in your to generate workbooks with Power Query in them, mainly targeting 'Export to Excel' features you have in your application.
13
+ Connected Workbooks allows you to avoid "data dumps" in CSV form, providing a richer experience with Tables and/or connected Queries for when your business application supports it.
6
14
 
7
- ### Basic Usage - using a predefined template:
15
+ [Learn about Power Query here](https://powerquery.microsoft.com/en-us/)
8
16
 
9
- The library comes with a workbook template built in, that loads a query named 'Query1' to a Query Table on the grid.
17
+ ## Where is this library used? here are some examples:
10
18
 
19
+ |<img src="https://github.com/microsoft/connected-workbooks/assets/7674478/b7a0c989-7ba4-4da8-851e-04650d8b600e" alt="Kusto" width="32"/>| <img src="https://github.com/microsoft/connected-workbooks/assets/7674478/76d22d23-5f2b-465f-992d-f1c71396904c" alt="LogAnalytics" width="32"/> | <img src="https://github.com/microsoft/connected-workbooks/assets/7674478/436b4f53-bf25-4c45-aae5-55ee1b1feafc" alt="Datamart" width="32"/> | <img src="https://github.com/microsoft/connected-workbooks/assets/7674478/3965f684-b461-42fe-9c62-e3059c0286eb" alt="VivaSales" width="32"/> |
20
+ |--------------------------------- |------------------- |-------------- |---------------- |
21
+ | **Azure Data Explorer** | **Log Analytics** | **Datamart** | **Viva Sales** |
22
+
23
+ ## How do I use it? here are some examples:
24
+
25
+ ### 1. Export a table directly from an Html page:
11
26
  ```typescript
12
- let workbookManager = new WorkbookManager();
13
- let blob = await workbookManager.generateSingleQueryWorkbook({
14
- queryMashup: query,
15
- refreshOnOpen: refreshOnOpen,
16
- });
27
+ import workbookManager from '@microsoft/connected-workbooks';
17
28
 
18
- Download(blob, filename);
29
+ const blob = await workbookManager.generateTableWorkbookFromHtml(document.querySelector('table') as HTMLTableElement);
30
+ workbookManager.downloadWorkbook(blob, "MyTable.xlsx");
31
+ ```
32
+
33
+ ### 2. Export a table from raw data:
34
+ ```
35
+ import workbookManager from '@microsoft/connected-workbooks';
36
+
37
+ const grid = {
38
+ "promoteHeaders": true,
39
+ "data": [
40
+ ["Product", "Price", "InStock", "Category", "Date"],
41
+ ["Widget A", 19.99, true, "Electronics", "10/26/2024"],
42
+ ["Gizmo B", 9.99, true, "Accessories", "10/26/2024"],
43
+ ["Bubala", 14.99, false, "Accessories", "10/22/2023"],
44
+ ["Thingamajig C", 50, false, "Tools", "5/12/2023"],
45
+ ["Doohickey D", 50.01, true, "Home", "8/12/2023"]
46
+ ]
47
+ };
48
+ const blob = await workbookManager.generateTableWorkbookFromGrid(grid);
49
+ workbookManager.downloadWorkbook(blob, "MyTable.xlsx");
19
50
  ```
51
+ <img width="281" alt="image" src="https://github.com/microsoft/connected-workbooks/assets/7674478/b91e5d69-8444-4a19-a4b0-3fd721e5576f">
20
52
 
21
- While a typical download method would be:
53
+ ### 3. Control Document Properties:
54
+ ```typescript
55
+ const blob = await workbookManager.generateTableWorkbookFromHtml(
56
+ document.querySelector('table') as HTMLTableElement,
57
+ {createdBy: 'John Doe', lastModifiedBy: 'Jane Doe', description: 'This is a sample table'});
58
+
59
+ workbookManager.downloadWorkbook(blob, "MyTable.xlsx");
60
+ ```
61
+ ![image](https://github.com/microsoft/connected-workbooks/assets/7674478/c267c9eb-6367-419d-832d-5a835c7683f9)
22
62
 
63
+ ### 4. Export a Power Query connected workbook:
23
64
  ```typescript
24
- function Download(file: Blob, filename: string) {
25
- if (window.navigator.msSaveOrOpenBlob)
26
- // IE10+
27
- window.navigator.msSaveOrOpenBlob(file, filename);
28
- else {
29
- // Others
30
- var a = document.createElement("a"),
31
- url = URL.createObjectURL(file);
32
- a.href = url;
33
- a.download = filename;
34
- document.body.appendChild(a);
35
- a.click();
36
- setTimeout(function () {
37
- document.body.removeChild(a);
38
- window.URL.revokeObjectURL(url);
39
- }, 0);
40
- }
41
- }
65
+ import workbookManager from '@microsoft/connected-workbooks';
66
+
67
+ const blob = await workbookManager.generateSingleQueryWorkbook({
68
+ queryMashup: 'let \
69
+ Source = {1..10} \
70
+ in \
71
+ Source',
72
+ refreshOnOpen: true});
73
+ workbookManager.downloadWorkbook(blob, "MyConnectedWorkbook.xlsx");
42
74
  ```
75
+ ![image](https://github.com/microsoft/connected-workbooks/assets/7674478/57bd986c-6309-4963-8d86-911ccf496c3f)
43
76
 
77
+ (after refreshing on open)
44
78
  ### Advanced Usage - bring your own template:
45
79
 
46
- You can use the library with your own template, for that (currently) there should be a single query named **Query1** loaded to a **Query Table**, **Pivot Table**, or **Pivot Chart** in the template workbook, and pass it as a **File** to the templateWorkbook parameter of the API:
80
+ You can use the library with your own workbook as a template!
47
81
 
48
82
  ```typescript
49
- let workbookManager = new WorkbookManager();
50
- let blob = await workbookManager.generateSingleQueryWorkbook(
51
- {
52
- queryMashup: query,
53
- refreshOnOpen: refreshOnOpen,
54
- },
55
- templateFile
56
- );
57
-
58
- Download(blob, filename);
83
+ const blob = await workbookManager.generateSingleQueryWorkbook(
84
+ { queryMashup: query, refreshOnOpen: true },
85
+ undefined /* optional Grid */,
86
+ templateFile);
87
+ workbookManager.downloadWorkbook(blob, "MyBrandedWorkbook.xlsx");
59
88
  ```
89
+ ![image](https://github.com/microsoft/connected-workbooks/assets/7674478/e5377946-4348-4229-9b88-1910ff7ee025)
60
90
 
61
- A common way to get the template workbook with React via user interaction:
91
+ Template requirements:
62
92
 
63
- ```typescript
64
- const [templateFile, setTemplateFile] = useState<File | null>(null);
93
+ Have a single query named **Query1** loaded to a **Query Table**, **Pivot Table**, or a **Pivot Chart**.
94
+
95
+
96
+ ⭐ Recommendation - have your product template baked and tested in your own product code, instead of your user providing it.
65
97
 
98
+ ⭐ For user templates - a common way to get the template workbook with React via user interaction:
99
+
100
+ ```typescript
101
+ const [templateFile, setTemplateFile] = useState<File | null>(null);
66
102
  ...
103
+ <input type="file" id="file" accept=".xlsx" style={{ display: "none" }} onChange={(e) => {
104
+ if (e?.target?.files?.item(0) == null) return;
105
+ setTemplateFile(e!.target!.files!.item(0));
106
+ }}/>
107
+ ```
108
+ ### API
109
+ The library exposes a workbookManager, which generates a workbook via several APIs:
67
110
 
68
- <input
69
- onChange={(e) => {
70
- if (e?.target?.files?.item(0) == null) return;
71
- setTemplateFile(e!.target!.files!.item(0));
72
- }}
73
- type="file"
74
- id="file"
75
- accept=".xlsx"
76
- style={{ display: "none" }}
77
- />
111
+ #### 1. Generate a Power Query connected workbook
112
+ ```typescript
113
+ async function `generateSingleQueryWorkbook`: `Promise<Blob>`
114
+ ```
115
+
116
+ |Parameter | Type | Required | Description |
117
+ |--- |--- |--- |--- |
118
+ |query | [QueryInfo](#queryinfo) | __required__ | Power Query mashup |
119
+ | grid | [Grid](#grid) | optional | Initial grid data |
120
+ | fileConfigs | [FileConfigs](#fileconfigs) | optional | Custom file configurations |
121
+
122
+ #### 2. Generate a table workbook from a Html page
123
+ ```typescript
124
+ async function `generateTableWorkbookFromHtml`: `Promise<Blob>`
125
+ ```
78
126
 
127
+ |Parameter | Type | Required | Description |
128
+ |--- |--- |--- |--- |
129
+ | htmlTable | HTMLTableElement | __required__ | Initial data loaded to workbook |
130
+ | docProps | [DocProps](#docprops) | optional | Custom workbook properties |
131
+
132
+ #### 3. Generate a table workbook with raw data
133
+ ```typescript
134
+ async function `generateTableWorkbookFromGrid`: `Promise<Blob>`
79
135
  ```
80
136
 
81
- Though expecation is that you have your product template baked and tested in your own product code, and not have the user provide it.
137
+ |Parameter | Type | Required | Description |
138
+ |--- |--- |--- |--- |
139
+ | grid | [Grid](#grid) | __required__ | Initial data loaded to workbook |
140
+ | docProps | [DocProps](#docprops) | optional | Custom workbook properties |
141
+ </br>
142
+
143
+ ### Types
144
+
145
+ #### QueryInfo
146
+ |Parameter | Type | Required | Description |
147
+ |---|---|---|---|
148
+ | queryMashup | string | __required__ | Mashup string
149
+ | refreshOnOpen | boolean | __required__ | Should workbook data refresh upon open
150
+ | queryName | string | optional | Query name, defaults to "Query1"
151
+
152
+ #### Grid
153
+ |Parameter | Type | Required | Description |
154
+ |---|---|---|---|
155
+ | data | (string | number | boolean)[][] | __required__ | Grid data
156
+ | promoteHeaders | boolean | optional | Should first row of gridData be used as the header, defaults to false - generating "Column1", "Column2"...
157
+
158
+
159
+ #### FileConfigs
160
+ |Parameter | Type | Required | Description |
161
+ |---|---|---|---|
162
+ | templateFile | File | optional | Custom Excel workbook |
163
+ | docProps | [DocProps](#docprops) | optional | Custom workbook properties |
164
+
165
+ #### DocProps
166
+ |Parameter | Type | Required
167
+ |---|---|---|
168
+ | title | string | optional
169
+ | subject | string | optional
170
+ | keywords | string | optional
171
+ | createdBy | string | optional
172
+ | description | string | optional
173
+ | lastModifiedBy | string | optional
174
+ | category | string | optional
175
+ | revision | number | optional
82
176
 
83
177
  ## Contributing
84
178
 
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseToTableData = void 0;
4
+ const constants_1 = require("./utils/constants");
5
+ const parseToTableData = (grid) => {
6
+ if (!grid) {
7
+ return undefined;
8
+ }
9
+ const columnNames = generateColumnNames(grid);
10
+ const rows = parseGridRows(grid);
11
+ return { columnNames: columnNames, rows: rows };
12
+ };
13
+ exports.parseToTableData = parseToTableData;
14
+ const parseGridRows = (grid) => {
15
+ const gridData = grid.data;
16
+ if (!gridData) {
17
+ throw new Error(constants_1.gridNotFoundErr);
18
+ }
19
+ const rows = [];
20
+ if (!grid.promoteHeaders) {
21
+ const row = [];
22
+ for (const prop in gridData[0]) {
23
+ const cellValue = gridData[0][prop];
24
+ row.push(cellValue.toString());
25
+ }
26
+ rows.push(row);
27
+ }
28
+ for (let i = 1; i < gridData.length; i++) {
29
+ const rowData = gridData[i];
30
+ const row = [];
31
+ for (const prop in rowData) {
32
+ const cellValue = rowData[prop];
33
+ row.push(cellValue.toString());
34
+ }
35
+ rows.push(row);
36
+ }
37
+ return rows;
38
+ };
39
+ const generateColumnNames = (grid) => {
40
+ if (grid.promoteHeaders) {
41
+ return grid.data[0].map((columnName) => columnName.toString());
42
+ }
43
+ const columnNames = [];
44
+ for (let i = 0; i < grid.data[0].length; i++) {
45
+ columnNames.push(`Column ${i + 1}`);
46
+ }
47
+ return columnNames;
48
+ };
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT license.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.generateCustomXmlFilePath = exports.generateSingleQueryMashup = exports.generateMashupXMLTemplate = void 0;
6
+ const generateMashupXMLTemplate = (base64) => `<?xml version="1.0" encoding="utf-16"?><DataMashup xmlns="http://schemas.microsoft.com/DataMashup">${base64}</DataMashup>`;
7
+ exports.generateMashupXMLTemplate = generateMashupXMLTemplate;
8
+ const generateSingleQueryMashup = (queryName, query) => `section Section1;
9
+
10
+ shared ${queryName} =
11
+ ${query};`;
12
+ exports.generateSingleQueryMashup = generateSingleQueryMashup;
13
+ const generateCustomXmlFilePath = (i) => `customXml/item${i}.xml`;
14
+ exports.generateCustomXmlFilePath = generateCustomXmlFilePath;
package/dist/index.d.ts CHANGED
@@ -1 +1,6 @@
1
- export { WorkbookManager, QueryInfo } from "./workbookManager";
1
+ import * as workbookManager from "./workbookManager";
2
+ import { DataTypes } from "./types";
3
+ import type { QueryInfo, FileConfigs, Grid } from "./types";
4
+ export { DataTypes };
5
+ export type { QueryInfo, FileConfigs, Grid };
6
+ export default workbookManager;
package/dist/index.js CHANGED
@@ -1,9 +1,32 @@
1
1
  "use strict";
2
2
  // Copyright (c) Microsoft Corporation.
3
3
  // Licensed under the MIT license.
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: function() { return m[k]; } };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
17
+ }) : function(o, v) {
18
+ o["default"] = v;
19
+ });
20
+ var __importStar = (this && this.__importStar) || function (mod) {
21
+ if (mod && mod.__esModule) return mod;
22
+ var result = {};
23
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24
+ __setModuleDefault(result, mod);
25
+ return result;
26
+ };
4
27
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.QueryInfo = exports.WorkbookManager = void 0;
6
- var workbookManager_1 = require("./workbookManager");
7
- Object.defineProperty(exports, "WorkbookManager", { enumerable: true, get: function () { return workbookManager_1.WorkbookManager; } });
8
- Object.defineProperty(exports, "QueryInfo", { enumerable: true, get: function () { return workbookManager_1.QueryInfo; } });
9
- //# sourceMappingURL=index.js.map
28
+ exports.DataTypes = void 0;
29
+ const workbookManager = __importStar(require("./workbookManager"));
30
+ const types_1 = require("./types");
31
+ Object.defineProperty(exports, "DataTypes", { enumerable: true, get: function () { return types_1.DataTypes; } });
32
+ exports.default = workbookManager;
@@ -0,0 +1,51 @@
1
+ export interface QueryInfo {
2
+ refreshOnOpen: boolean;
3
+ queryMashup: string;
4
+ queryName?: string;
5
+ }
6
+ export interface DocProps {
7
+ title?: string | null;
8
+ subject?: string | null;
9
+ keywords?: string | null;
10
+ createdBy?: string | null;
11
+ description?: string | null;
12
+ lastModifiedBy?: string | null;
13
+ category?: string | null;
14
+ revision?: string | null;
15
+ }
16
+ export interface Metadata {
17
+ queryName: string;
18
+ }
19
+ export interface TableData {
20
+ columnNames: string[];
21
+ rows: string[][];
22
+ columnwidth?: number;
23
+ }
24
+ export interface Grid {
25
+ data: (string | number | boolean)[][];
26
+ promoteHeaders?: boolean;
27
+ }
28
+ export interface FileConfigs {
29
+ templateFile?: File;
30
+ docProps?: DocProps;
31
+ }
32
+ export declare enum DataTypes {
33
+ null = 0,
34
+ string = 1,
35
+ number = 2,
36
+ boolean = 3
37
+ }
38
+ export declare enum DocPropsModifiableElements {
39
+ title = "dc:title",
40
+ subject = "dc:subject",
41
+ keywords = "cp:keywords",
42
+ createdBy = "dc:creator",
43
+ description = "dc:description",
44
+ lastModifiedBy = "cp:lastModifiedBy",
45
+ category = "cp:category",
46
+ revision = "cp:revision"
47
+ }
48
+ export declare enum DocPropsAutoUpdatedElements {
49
+ created = "dcterms:created",
50
+ modified = "dcterms:modified"
51
+ }
package/dist/types.js ADDED
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT license.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.DocPropsAutoUpdatedElements = exports.DocPropsModifiableElements = exports.DataTypes = void 0;
6
+ var DataTypes;
7
+ (function (DataTypes) {
8
+ DataTypes[DataTypes["null"] = 0] = "null";
9
+ DataTypes[DataTypes["string"] = 1] = "string";
10
+ DataTypes[DataTypes["number"] = 2] = "number";
11
+ DataTypes[DataTypes["boolean"] = 3] = "boolean";
12
+ })(DataTypes = exports.DataTypes || (exports.DataTypes = {}));
13
+ var DocPropsModifiableElements;
14
+ (function (DocPropsModifiableElements) {
15
+ DocPropsModifiableElements["title"] = "dc:title";
16
+ DocPropsModifiableElements["subject"] = "dc:subject";
17
+ DocPropsModifiableElements["keywords"] = "cp:keywords";
18
+ DocPropsModifiableElements["createdBy"] = "dc:creator";
19
+ DocPropsModifiableElements["description"] = "dc:description";
20
+ DocPropsModifiableElements["lastModifiedBy"] = "cp:lastModifiedBy";
21
+ DocPropsModifiableElements["category"] = "cp:category";
22
+ DocPropsModifiableElements["revision"] = "cp:revision";
23
+ })(DocPropsModifiableElements = exports.DocPropsModifiableElements || (exports.DocPropsModifiableElements = {}));
24
+ var DocPropsAutoUpdatedElements;
25
+ (function (DocPropsAutoUpdatedElements) {
26
+ DocPropsAutoUpdatedElements["created"] = "dcterms:created";
27
+ DocPropsAutoUpdatedElements["modified"] = "dcterms:modified";
28
+ })(DocPropsAutoUpdatedElements = exports.DocPropsAutoUpdatedElements || (exports.DocPropsAutoUpdatedElements = {}));
@@ -2,19 +2,19 @@
2
2
  // Copyright (c) Microsoft Corporation.
3
3
  // Licensed under the MIT license.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.concatArrays = exports.getInt32Buffer = exports.ArrayReader = void 0;
5
+ exports.ArrayReader = void 0;
6
6
  class ArrayReader {
7
7
  constructor(array) {
8
8
  this._array = array;
9
9
  this._position = 0;
10
10
  }
11
11
  getInt32() {
12
- let retVal = new DataView(this._array, this._position, 4).getInt32(0, true);
12
+ const retVal = new DataView(this._array, this._position, 4).getInt32(0, true);
13
13
  this._position += 4;
14
14
  return retVal;
15
15
  }
16
16
  getBytes(bytes) {
17
- let retVal = this._array.slice(this._position, (bytes ? bytes + this._position : bytes));
17
+ const retVal = this._array.slice(this._position, bytes ? bytes + this._position : bytes);
18
18
  this._position += retVal.byteLength;
19
19
  return new Uint8Array(retVal);
20
20
  }
@@ -24,21 +24,23 @@ class ArrayReader {
24
24
  }
25
25
  exports.ArrayReader = ArrayReader;
26
26
  function getInt32Buffer(val) {
27
- let packageSizeBuffer = new ArrayBuffer(4);
27
+ const packageSizeBuffer = new ArrayBuffer(4);
28
28
  new DataView(packageSizeBuffer).setInt32(0, val, true);
29
29
  return new Uint8Array(packageSizeBuffer);
30
30
  }
31
- exports.getInt32Buffer = getInt32Buffer;
32
31
  function concatArrays(...args) {
33
32
  let size = 0;
34
- args.forEach(arr => size += arr.byteLength);
35
- let retVal = new Uint8Array(size);
33
+ args.forEach((arr) => (size += arr.byteLength));
34
+ const retVal = new Uint8Array(size);
36
35
  let position = 0;
37
- args.forEach(arr => {
36
+ args.forEach((arr) => {
38
37
  retVal.set(arr, position);
39
38
  position += arr.byteLength;
40
39
  });
41
40
  return retVal;
42
41
  }
43
- exports.concatArrays = concatArrays;
44
- //# sourceMappingURL=arrayUtils.js.map
42
+ exports.default = {
43
+ ArrayReader,
44
+ getInt32Buffer,
45
+ concatArrays,
46
+ };
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT license.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.defaults = exports.elementAttributesValues = exports.dataTypeKind = exports.elementAttributes = exports.element = exports.BOM = exports.falseStr = exports.trueStr = exports.maxQueryLength = exports.divider = exports.section1PathPrefix = exports.emptyValue = exports.falseValue = exports.trueValue = exports.pivotCachesPathPrefix = exports.xmlTextResultType = exports.textResultType = exports.application = exports.uint8ArrayType = exports.blobFileType = exports.stylesNotFoundErr = exports.EmptyQueryNameErr = exports.QueryNameMaxLengthErr = exports.invalidDataTypeErr = exports.headerNotFoundErr = exports.invalidValueInColumnErr = exports.gridNotFoundErr = exports.tableNotFoundErr = exports.queryTableNotFoundErr = exports.templateWithInitialDataErr = exports.formulaSectionNotFoundErr = exports.queryConnectionNotFoundErr = exports.queryAndPivotTableNotFoundErr = exports.queryNameNotFoundErr = exports.emptyQueryMashupErr = exports.base64NotFoundErr = exports.sheetsNotFoundErr = exports.connectionsNotFoundErr = exports.sharedStringsNotFoundErr = exports.docPropsRootElement = exports.docPropsCoreXmlPath = exports.section1mPath = exports.pivotCachesPath = exports.queryTablesPath = exports.workbookXmlPath = exports.queryTableXmlPath = exports.tableXmlPath = exports.sheetsXmlPath = exports.sharedStringsXmlPath = exports.connectionsXmlPath = void 0;
6
+ exports.URLS = void 0;
7
+ exports.connectionsXmlPath = "xl/connections.xml";
8
+ exports.sharedStringsXmlPath = "xl/sharedStrings.xml";
9
+ exports.sheetsXmlPath = "xl/worksheets/sheet1.xml";
10
+ exports.tableXmlPath = "xl/tables/table1.xml";
11
+ exports.queryTableXmlPath = "xl/queryTables/queryTable1.xml";
12
+ exports.workbookXmlPath = "xl/workbook.xml";
13
+ exports.queryTablesPath = "xl/queryTables/";
14
+ exports.pivotCachesPath = "xl/pivotCache/";
15
+ exports.section1mPath = "Formulas/Section1.m";
16
+ exports.docPropsCoreXmlPath = "docProps/core.xml";
17
+ exports.docPropsRootElement = "cp:coreProperties";
18
+ exports.sharedStringsNotFoundErr = "SharedStrings were not found in template";
19
+ exports.connectionsNotFoundErr = "Connections were not found in template";
20
+ exports.sheetsNotFoundErr = "Sheets were not found in template";
21
+ exports.base64NotFoundErr = "Base64 was not found in template";
22
+ exports.emptyQueryMashupErr = "Query mashup is empty";
23
+ exports.queryNameNotFoundErr = "Query name was not found";
24
+ exports.queryAndPivotTableNotFoundErr = "No such query found in Query Table or Pivot Table found in given template";
25
+ exports.queryConnectionNotFoundErr = "No connection found for query";
26
+ exports.formulaSectionNotFoundErr = "Formula section wasn't found in template";
27
+ exports.templateWithInitialDataErr = "Cannot receive template file with initial data";
28
+ exports.queryTableNotFoundErr = "Query table wasn't found in template";
29
+ exports.tableNotFoundErr = "Table wasn't found in template";
30
+ exports.gridNotFoundErr = "Invalid JSON file, grid data is missing";
31
+ exports.invalidValueInColumnErr = "Invalid cell value in column";
32
+ exports.headerNotFoundErr = "Invalid JSON file, header is missing";
33
+ exports.invalidDataTypeErr = "Invalid JSON file, invalid data type";
34
+ exports.QueryNameMaxLengthErr = "Query names are limited to 80 characters";
35
+ exports.EmptyQueryNameErr = "Query name cannot be empty";
36
+ exports.stylesNotFoundErr = "Styles were not found in template";
37
+ exports.blobFileType = "blob";
38
+ exports.uint8ArrayType = "uint8array";
39
+ exports.application = "application/xlsx";
40
+ exports.textResultType = "text";
41
+ exports.xmlTextResultType = "text/xml";
42
+ exports.pivotCachesPathPrefix = "pivotCacheDefinition";
43
+ exports.trueValue = "1";
44
+ exports.falseValue = "0";
45
+ exports.emptyValue = "";
46
+ exports.section1PathPrefix = "Section1/";
47
+ exports.divider = "/";
48
+ exports.maxQueryLength = 80;
49
+ exports.trueStr = "true";
50
+ exports.falseStr = "false";
51
+ exports.BOM = '\ufeff';
52
+ exports.element = {
53
+ sharedStringTable: "sst",
54
+ text: "t",
55
+ sharedStringItem: "si",
56
+ cellValue: "v",
57
+ databaseProperties: "dbPr",
58
+ queryTable: "queryTable",
59
+ cacheSource: "cacheSource",
60
+ item: "Item",
61
+ items: "Items",
62
+ itemPath: "ItemPath",
63
+ itemType: "ItemType",
64
+ itemLocation: "ItemLocation",
65
+ entry: "Entry",
66
+ stableEntries: "StableEntries",
67
+ tableColumns: "tableColumns",
68
+ tableColumn: "tableColumn",
69
+ table: "table",
70
+ autoFilter: "autoFilter",
71
+ definedName: "definedName",
72
+ queryTableFields: "queryTableFields",
73
+ queryTableField: "queryTableField",
74
+ queryTableRefresh: "queryTableRefresh",
75
+ sheetData: "sheetData",
76
+ row: "row",
77
+ dimension: "dimension",
78
+ kindCell: "c"
79
+ };
80
+ exports.elementAttributes = {
81
+ connection: "connection",
82
+ command: "command",
83
+ refreshOnLoad: "refreshOnLoad",
84
+ count: "count",
85
+ uniqueCount: "uniqueCount",
86
+ queryTable: "queryTable",
87
+ connectionId: "connectionId",
88
+ cacheSource: "cacheSource",
89
+ name: "name",
90
+ description: "description",
91
+ id: "id",
92
+ type: "Type",
93
+ value: "Value",
94
+ relationshipInfo: "RelationshipInfoContainer",
95
+ resultType: "ResultType",
96
+ fillColumnNames: "FillColumnNames",
97
+ fillTarget: "FillTarget",
98
+ fillLastUpdated: "FillLastUpdated",
99
+ day: "d",
100
+ uniqueName: "uniqueName",
101
+ queryTableFieldId: "queryTableFieldId",
102
+ reference: "ref",
103
+ tableColumnId: "tableColumnId",
104
+ nextId: "nextId",
105
+ row: "r",
106
+ spans: "spans",
107
+ x14acDyDescent: "x14ac:dyDescent",
108
+ xr3uid: "xr3:uid",
109
+ };
110
+ exports.dataTypeKind = {
111
+ string: "str",
112
+ number: "1",
113
+ boolean: "b",
114
+ };
115
+ exports.elementAttributesValues = {
116
+ connectionName: (queryName) => `Query - ${queryName}`,
117
+ connectionDescription: (queryName) => `Connection to the '${queryName}' query in the workbook.`,
118
+ connection: (queryName) => `Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=${queryName};`,
119
+ connectionCommand: (queryName) => `SELECT * FROM [${queryName}]`,
120
+ tableResultType: () => "sTable"
121
+ };
122
+ exports.defaults = {
123
+ queryName: "Query1",
124
+ sheetName: "Sheet1"
125
+ };
126
+ exports.URLS = {
127
+ PQ: [
128
+ "http://schemas.microsoft.com/DataMashup",
129
+ "http://schemas.microsoft.com/DataExplorer",
130
+ "http://schemas.microsoft.com/DataMashup/Temp",
131
+ "http://schemas.microsoft.com/DataExplorer/Temp",
132
+ ],
133
+ CONNECTED_WORKBOOK: "http://schemas.microsoft.com/ConnectedWorkbook",
134
+ };