@microsoft/connected-workbooks 3.1.1-beta.2 → 3.1.2-beta.2
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/generators.js +9 -3
- package/dist/index.d.ts +1 -2
- package/dist/index.js +29 -4
- package/dist/types.js +9 -6
- package/dist/utils/arrayUtils.js +5 -2
- package/dist/utils/constants.js +65 -60
- package/dist/utils/documentUtils.js +42 -27
- package/dist/utils/gridUtils.js +10 -8
- package/dist/utils/htmlUtils.js +3 -1
- package/dist/utils/index.js +22 -8
- package/dist/utils/mashupDocumentParser.js +70 -47
- package/dist/utils/pqUtils.js +19 -15
- package/dist/utils/tableUtils.js +69 -63
- package/dist/utils/xmlInnerPartsUtils.js +80 -74
- package/dist/utils/xmlPartsUtils.js +31 -26
- package/dist/workbookManager.js +46 -35
- package/dist/workbookTemplate.js +5 -2
- package/package.json +4 -2
package/dist/generators.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// Copyright (c) Microsoft Corporation.
|
|
2
3
|
// Licensed under the MIT license.
|
|
3
|
-
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.generateCustomXmlFilePath = exports.generateSingleQueryMashup = exports.generateMashupXMLTemplate = void 0;
|
|
6
|
+
var generateMashupXMLTemplate = function (base64) {
|
|
4
7
|
return "<?xml version=\"1.0\" encoding=\"utf-16\"?><DataMashup xmlns=\"http://schemas.microsoft.com/DataMashup\">".concat(base64, "</DataMashup>");
|
|
5
8
|
};
|
|
6
|
-
|
|
9
|
+
exports.generateMashupXMLTemplate = generateMashupXMLTemplate;
|
|
10
|
+
var generateSingleQueryMashup = function (queryName, query) {
|
|
7
11
|
return "section Section1;\n \n shared #\"".concat(queryName, "\" = \n ").concat(query, ";");
|
|
8
12
|
};
|
|
9
|
-
|
|
13
|
+
exports.generateSingleQueryMashup = generateSingleQueryMashup;
|
|
14
|
+
var generateCustomXmlFilePath = function (i) { return "customXml/item".concat(i, ".xml"); };
|
|
15
|
+
exports.generateCustomXmlFilePath = generateCustomXmlFilePath;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import * as workbookManager from "./workbookManager";
|
|
2
1
|
import { DataTypes } from "./types";
|
|
3
2
|
import type { QueryInfo, FileConfigs, Grid, DocProps } from "./types";
|
|
4
3
|
export { DataTypes };
|
|
5
4
|
export type { QueryInfo, FileConfigs, Grid, DocProps };
|
|
6
|
-
export
|
|
5
|
+
export * as workbookManager from "./workbookManager";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// Copyright (c) Microsoft Corporation.
|
|
2
3
|
// Licensed under the MIT license.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.workbookManager = exports.DataTypes = void 0;
|
|
29
|
+
var types_1 = require("./types");
|
|
30
|
+
Object.defineProperty(exports, "DataTypes", { enumerable: true, get: function () { return types_1.DataTypes; } });
|
|
31
|
+
exports.workbookManager = __importStar(require("./workbookManager"));
|
package/dist/types.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// Copyright (c) Microsoft Corporation.
|
|
2
3
|
// Licensed under the MIT license.
|
|
3
|
-
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.DocPropsAutoUpdatedElements = exports.DocPropsModifiableElements = exports.DataTypes = void 0;
|
|
6
|
+
var DataTypes;
|
|
4
7
|
(function (DataTypes) {
|
|
5
8
|
DataTypes[DataTypes["null"] = 0] = "null";
|
|
6
9
|
DataTypes[DataTypes["string"] = 1] = "string";
|
|
7
10
|
DataTypes[DataTypes["number"] = 2] = "number";
|
|
8
11
|
DataTypes[DataTypes["boolean"] = 3] = "boolean";
|
|
9
|
-
})(DataTypes || (DataTypes = {}));
|
|
10
|
-
|
|
12
|
+
})(DataTypes = exports.DataTypes || (exports.DataTypes = {}));
|
|
13
|
+
var DocPropsModifiableElements;
|
|
11
14
|
(function (DocPropsModifiableElements) {
|
|
12
15
|
DocPropsModifiableElements["title"] = "dc:title";
|
|
13
16
|
DocPropsModifiableElements["subject"] = "dc:subject";
|
|
@@ -17,9 +20,9 @@ export var DocPropsModifiableElements;
|
|
|
17
20
|
DocPropsModifiableElements["lastModifiedBy"] = "cp:lastModifiedBy";
|
|
18
21
|
DocPropsModifiableElements["category"] = "cp:category";
|
|
19
22
|
DocPropsModifiableElements["revision"] = "cp:revision";
|
|
20
|
-
})(DocPropsModifiableElements || (DocPropsModifiableElements = {}));
|
|
21
|
-
|
|
23
|
+
})(DocPropsModifiableElements = exports.DocPropsModifiableElements || (exports.DocPropsModifiableElements = {}));
|
|
24
|
+
var DocPropsAutoUpdatedElements;
|
|
22
25
|
(function (DocPropsAutoUpdatedElements) {
|
|
23
26
|
DocPropsAutoUpdatedElements["created"] = "dcterms:created";
|
|
24
27
|
DocPropsAutoUpdatedElements["modified"] = "dcterms:modified";
|
|
25
|
-
})(DocPropsAutoUpdatedElements || (DocPropsAutoUpdatedElements = {}));
|
|
28
|
+
})(DocPropsAutoUpdatedElements = exports.DocPropsAutoUpdatedElements || (exports.DocPropsAutoUpdatedElements = {}));
|
package/dist/utils/arrayUtils.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// Copyright (c) Microsoft Corporation.
|
|
2
3
|
// Licensed under the MIT license.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.ArrayReader = void 0;
|
|
3
6
|
var ArrayReader = /** @class */ (function () {
|
|
4
7
|
function ArrayReader(array) {
|
|
5
8
|
this._array = array;
|
|
@@ -20,7 +23,7 @@ var ArrayReader = /** @class */ (function () {
|
|
|
20
23
|
};
|
|
21
24
|
return ArrayReader;
|
|
22
25
|
}());
|
|
23
|
-
|
|
26
|
+
exports.ArrayReader = ArrayReader;
|
|
24
27
|
function getInt32Buffer(val) {
|
|
25
28
|
var packageSizeBuffer = new ArrayBuffer(4);
|
|
26
29
|
new DataView(packageSizeBuffer).setInt32(0, val, true);
|
|
@@ -41,7 +44,7 @@ function concatArrays() {
|
|
|
41
44
|
});
|
|
42
45
|
return retVal;
|
|
43
46
|
}
|
|
44
|
-
|
|
47
|
+
exports.default = {
|
|
45
48
|
ArrayReader: ArrayReader,
|
|
46
49
|
getInt32Buffer: getInt32Buffer,
|
|
47
50
|
concatArrays: concatArrays,
|
package/dist/utils/constants.js
CHANGED
|
@@ -1,58 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// Copyright (c) Microsoft Corporation.
|
|
2
3
|
// Licensed under the MIT license.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
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.columnIndexOutOfRangeErr = exports.relsNotFoundErr = exports.arrayIsntMxNErr = exports.unexpectedErr = exports.promotedHeadersCannotBeUsedWithoutAdjustingColumnNamesErr = exports.InvalidColumnNameErr = exports.stylesNotFoundErr = exports.EmptyQueryNameErr = exports.QueryNameInvalidCharsErr = exports.QueryNameMaxLengthErr = exports.invalidDataTypeErr = exports.headerNotFoundErr = exports.invalidValueInColumnErr = 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.docMetadataXmlPath = exports.relsXmlPath = exports.docPropsCoreXmlPath = exports.section1mPath = exports.pivotCachesPath = exports.queryTablesPath = exports.workbookXmlPath = exports.queryTableXmlPath = exports.tableXmlPath = exports.sheetsXmlPath = exports.sharedStringsXmlPath = exports.connectionsXmlPath = void 0;
|
|
6
|
+
exports.OFU = exports.headers = exports.URLS = exports.defaults = exports.elementAttributesValues = exports.dataTypeKind = exports.elementAttributes = exports.element = exports.BOM = exports.falseStr = exports.trueStr = 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.relsXmlPath = "_rels/.rels";
|
|
18
|
+
exports.docMetadataXmlPath = "docMetadata";
|
|
19
|
+
exports.docPropsRootElement = "cp:coreProperties";
|
|
20
|
+
exports.sharedStringsNotFoundErr = "SharedStrings were not found in template";
|
|
21
|
+
exports.connectionsNotFoundErr = "Connections were not found in template";
|
|
22
|
+
exports.sheetsNotFoundErr = "Sheets were not found in template";
|
|
23
|
+
exports.base64NotFoundErr = "Base64 was not found in template";
|
|
24
|
+
exports.emptyQueryMashupErr = "Query mashup is empty";
|
|
25
|
+
exports.queryNameNotFoundErr = "Query name was not found";
|
|
26
|
+
exports.queryAndPivotTableNotFoundErr = "No such query found in Query Table or Pivot Table found in given template";
|
|
27
|
+
exports.queryConnectionNotFoundErr = "No connection found for query";
|
|
28
|
+
exports.formulaSectionNotFoundErr = "Formula section wasn't found in template";
|
|
29
|
+
exports.templateWithInitialDataErr = "Cannot use a template file with initial data";
|
|
30
|
+
exports.queryTableNotFoundErr = "Query table wasn't found in template";
|
|
31
|
+
exports.tableNotFoundErr = "Table wasn't found in template";
|
|
32
|
+
exports.invalidValueInColumnErr = "Invalid cell value in column";
|
|
33
|
+
exports.headerNotFoundErr = "Invalid JSON file, header is missing";
|
|
34
|
+
exports.invalidDataTypeErr = "Invalid JSON file, invalid data type";
|
|
35
|
+
exports.QueryNameMaxLengthErr = "Query names are limited to 80 characters";
|
|
36
|
+
exports.QueryNameInvalidCharsErr = 'Query names cannot contain periods or quotation marks. (. ")';
|
|
37
|
+
exports.EmptyQueryNameErr = "Query name cannot be empty";
|
|
38
|
+
exports.stylesNotFoundErr = "Styles were not found in template";
|
|
39
|
+
exports.InvalidColumnNameErr = "Invalid column name";
|
|
40
|
+
exports.promotedHeadersCannotBeUsedWithoutAdjustingColumnNamesErr = "Headers cannot be promoted without adjusting column names";
|
|
41
|
+
exports.unexpectedErr = "Unexpected error";
|
|
42
|
+
exports.arrayIsntMxNErr = "Array isn't MxN";
|
|
43
|
+
exports.relsNotFoundErr = ".rels were not found in template";
|
|
44
|
+
exports.columnIndexOutOfRangeErr = "Column index out of range";
|
|
45
|
+
exports.blobFileType = "blob";
|
|
46
|
+
exports.uint8ArrayType = "uint8array";
|
|
47
|
+
exports.application = "application/xlsx";
|
|
48
|
+
exports.textResultType = "text";
|
|
49
|
+
exports.xmlTextResultType = "text/xml";
|
|
50
|
+
exports.pivotCachesPathPrefix = "pivotCacheDefinition";
|
|
51
|
+
exports.trueValue = "1";
|
|
52
|
+
exports.falseValue = "0";
|
|
53
|
+
exports.emptyValue = "";
|
|
54
|
+
exports.section1PathPrefix = "Section1/";
|
|
55
|
+
exports.divider = "/";
|
|
56
|
+
exports.maxQueryLength = 80;
|
|
57
|
+
exports.trueStr = "true";
|
|
58
|
+
exports.falseStr = "false";
|
|
59
|
+
exports.BOM = "\ufeff";
|
|
60
|
+
exports.element = {
|
|
56
61
|
sharedStringTable: "sst",
|
|
57
62
|
text: "t",
|
|
58
63
|
sharedStringItem: "si",
|
|
@@ -81,7 +86,7 @@ export var element = {
|
|
|
81
86
|
selection: "selection",
|
|
82
87
|
kindCell: "c",
|
|
83
88
|
};
|
|
84
|
-
|
|
89
|
+
exports.elementAttributes = {
|
|
85
90
|
connection: "connection",
|
|
86
91
|
command: "command",
|
|
87
92
|
refreshOnLoad: "refreshOnLoad",
|
|
@@ -113,24 +118,24 @@ export var elementAttributes = {
|
|
|
113
118
|
xr3uid: "xr3:uid",
|
|
114
119
|
space: "xml:space",
|
|
115
120
|
};
|
|
116
|
-
|
|
121
|
+
exports.dataTypeKind = {
|
|
117
122
|
string: "str",
|
|
118
123
|
number: "1",
|
|
119
124
|
boolean: "b",
|
|
120
125
|
};
|
|
121
|
-
|
|
126
|
+
exports.elementAttributesValues = {
|
|
122
127
|
connectionName: function (queryName) { return "Query - ".concat(queryName); },
|
|
123
128
|
connectionDescription: function (queryName) { return "Connection to the '".concat(queryName, "' query in the workbook."); },
|
|
124
129
|
connection: function (queryName) { return "Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=\"".concat(queryName, "\";"); },
|
|
125
130
|
connectionCommand: function (queryName) { return "SELECT * FROM [".concat(queryName, "]"); },
|
|
126
131
|
tableResultType: function () { return "sTable"; },
|
|
127
132
|
};
|
|
128
|
-
|
|
133
|
+
exports.defaults = {
|
|
129
134
|
queryName: "Query1",
|
|
130
135
|
sheetName: "Sheet1",
|
|
131
136
|
columnName: "Column",
|
|
132
137
|
};
|
|
133
|
-
|
|
138
|
+
exports.URLS = {
|
|
134
139
|
PQ: [
|
|
135
140
|
"http://schemas.microsoft.com/DataMashup",
|
|
136
141
|
"http://schemas.microsoft.com/DataExplorer",
|
|
@@ -140,10 +145,10 @@ export var URLS = {
|
|
|
140
145
|
CONNECTED_WORKBOOK: "http://schemas.microsoft.com/ConnectedWorkbook",
|
|
141
146
|
};
|
|
142
147
|
// Content-Type header to indicate that the content is an Excel document
|
|
143
|
-
|
|
148
|
+
exports.headers = {
|
|
144
149
|
"Content-Type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
145
150
|
};
|
|
146
|
-
|
|
151
|
+
exports.OFU = {
|
|
147
152
|
ViewUrl: "https://view.officeapps.live.com/op/view.aspx?src=http://connectedWorkbooks.excel/",
|
|
148
153
|
PostUrl: "https://view.officeapps.live.com/op/viewpost.aspx?src=http://connectedWorkbooks.excel/",
|
|
149
154
|
allowTyping: "AllowTyping",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// Copyright (c) Microsoft Corporation.
|
|
2
3
|
// Licensed under the MIT license.
|
|
3
4
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
@@ -36,8 +37,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
37
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
37
38
|
}
|
|
38
39
|
};
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
var constants_1 = require("./constants");
|
|
42
|
+
var types_1 = require("../types");
|
|
43
|
+
var xmldom_qsa_1 = require("xmldom-qsa");
|
|
41
44
|
var createOrUpdateProperty = function (doc, parent, property, value) {
|
|
42
45
|
if (value === undefined) {
|
|
43
46
|
return;
|
|
@@ -60,15 +63,15 @@ var getDocPropsProperties = function (zip) { return __awaiter(void 0, void 0, vo
|
|
|
60
63
|
var _a;
|
|
61
64
|
return __generator(this, function (_b) {
|
|
62
65
|
switch (_b.label) {
|
|
63
|
-
case 0: return [4 /*yield*/, ((_a = zip.file(docPropsCoreXmlPath)) === null || _a === void 0 ? void 0 : _a.async(textResultType))];
|
|
66
|
+
case 0: return [4 /*yield*/, ((_a = zip.file(constants_1.docPropsCoreXmlPath)) === null || _a === void 0 ? void 0 : _a.async(constants_1.textResultType))];
|
|
64
67
|
case 1:
|
|
65
68
|
docPropsCoreXmlString = _b.sent();
|
|
66
69
|
if (docPropsCoreXmlString === undefined) {
|
|
67
70
|
throw new Error("DocProps core.xml was not found in template");
|
|
68
71
|
}
|
|
69
|
-
parser = new DOMParser();
|
|
70
|
-
doc = parser.parseFromString(docPropsCoreXmlString, xmlTextResultType);
|
|
71
|
-
properties = doc.getElementsByTagName(docPropsRootElement).item(0);
|
|
72
|
+
parser = new xmldom_qsa_1.DOMParser();
|
|
73
|
+
doc = parser.parseFromString(docPropsCoreXmlString, constants_1.xmlTextResultType);
|
|
74
|
+
properties = doc.getElementsByTagName(constants_1.docPropsRootElement).item(0);
|
|
72
75
|
if (properties === null) {
|
|
73
76
|
throw new Error("Invalid DocProps core.xml");
|
|
74
77
|
}
|
|
@@ -77,56 +80,67 @@ var getDocPropsProperties = function (zip) { return __awaiter(void 0, void 0, vo
|
|
|
77
80
|
});
|
|
78
81
|
}); };
|
|
79
82
|
var getCellReferenceAbsolute = function (col, row) {
|
|
80
|
-
|
|
81
|
-
return "$" + String.fromCharCode(col + 65) + "$" + row.toString();
|
|
83
|
+
return "$" + convertToExcelColumn(col) + "$" + row.toString();
|
|
82
84
|
};
|
|
83
85
|
var getCellReferenceRelative = function (col, row) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
return convertToExcelColumn(col) + row.toString();
|
|
87
|
+
};
|
|
88
|
+
var convertToExcelColumn = function (index) {
|
|
89
|
+
if (index >= 16384) {
|
|
90
|
+
throw new Error(constants_1.columnIndexOutOfRangeErr);
|
|
91
|
+
}
|
|
92
|
+
var columnStr = "";
|
|
93
|
+
var base = 26; // number of letters in the alphabet
|
|
94
|
+
while (index >= 0) {
|
|
95
|
+
var remainder = index % base;
|
|
96
|
+
columnStr = String.fromCharCode(remainder + 65) + columnStr; // ASCII 'A' is 65
|
|
97
|
+
index = Math.floor(index / base) - 1;
|
|
98
|
+
}
|
|
99
|
+
return columnStr;
|
|
86
100
|
};
|
|
87
101
|
var getTableReference = function (numberOfCols, numberOfRows) {
|
|
88
102
|
return "A1:".concat(getCellReferenceRelative(numberOfCols, numberOfRows));
|
|
89
103
|
};
|
|
90
104
|
var createCellElement = function (doc, colIndex, rowIndex, data) {
|
|
91
|
-
var cell = doc.createElementNS(doc.documentElement.namespaceURI, element.kindCell);
|
|
92
|
-
cell.setAttribute(elementAttributes.row, getCellReferenceRelative(colIndex, rowIndex + 1));
|
|
93
|
-
var cellData = doc.createElementNS(doc.documentElement.namespaceURI, element.cellValue);
|
|
105
|
+
var cell = doc.createElementNS(doc.documentElement.namespaceURI, constants_1.element.kindCell);
|
|
106
|
+
cell.setAttribute(constants_1.elementAttributes.row, getCellReferenceRelative(colIndex, rowIndex + 1));
|
|
107
|
+
var cellData = doc.createElementNS(doc.documentElement.namespaceURI, constants_1.element.cellValue);
|
|
94
108
|
updateCellData(data, cell, cellData, rowIndex === 0);
|
|
95
109
|
cell.appendChild(cellData);
|
|
96
110
|
return cell;
|
|
97
111
|
};
|
|
98
112
|
var updateCellData = function (data, cell, cellData, rowHeader) {
|
|
99
113
|
switch (resolveType(data, rowHeader)) {
|
|
100
|
-
case DataTypes.string:
|
|
101
|
-
cell.setAttribute(element.text, dataTypeKind.string);
|
|
114
|
+
case types_1.DataTypes.string:
|
|
115
|
+
cell.setAttribute(constants_1.element.text, constants_1.dataTypeKind.string);
|
|
102
116
|
break;
|
|
103
|
-
case DataTypes.number:
|
|
104
|
-
cell.setAttribute(element.text, dataTypeKind.number);
|
|
117
|
+
case types_1.DataTypes.number:
|
|
118
|
+
cell.setAttribute(constants_1.element.text, constants_1.dataTypeKind.number);
|
|
105
119
|
break;
|
|
106
|
-
case DataTypes.boolean:
|
|
107
|
-
cell.setAttribute(element.text, dataTypeKind.boolean);
|
|
120
|
+
case types_1.DataTypes.boolean:
|
|
121
|
+
cell.setAttribute(constants_1.element.text, constants_1.dataTypeKind.boolean);
|
|
108
122
|
break;
|
|
109
123
|
}
|
|
110
124
|
if (data.startsWith(" ") || data.endsWith(" ")) {
|
|
111
|
-
cellData.setAttribute(elementAttributes.space, "preserve");
|
|
125
|
+
cellData.setAttribute(constants_1.elementAttributes.space, "preserve");
|
|
112
126
|
}
|
|
113
127
|
cellData.textContent = data;
|
|
114
128
|
};
|
|
115
129
|
var resolveType = function (originalData, rowHeader) {
|
|
116
130
|
var data = originalData;
|
|
117
|
-
if (
|
|
131
|
+
if (rowHeader || data.trim() === "") {
|
|
118
132
|
// Headers and whitespace should be string by default.
|
|
119
|
-
return DataTypes.string;
|
|
133
|
+
return types_1.DataTypes.string;
|
|
120
134
|
}
|
|
121
|
-
var dataType = isNaN(Number(data)) ? DataTypes.string : DataTypes.number;
|
|
122
|
-
if (dataType == DataTypes.string) {
|
|
123
|
-
if (data.trim() == trueStr || data.trim() == falseStr) {
|
|
124
|
-
dataType = DataTypes.boolean;
|
|
135
|
+
var dataType = isNaN(Number(data)) ? types_1.DataTypes.string : types_1.DataTypes.number;
|
|
136
|
+
if (dataType == types_1.DataTypes.string) {
|
|
137
|
+
if (data.trim() == constants_1.trueStr || data.trim() == constants_1.falseStr) {
|
|
138
|
+
dataType = types_1.DataTypes.boolean;
|
|
125
139
|
}
|
|
126
140
|
}
|
|
127
141
|
return dataType;
|
|
128
142
|
};
|
|
129
|
-
|
|
143
|
+
exports.default = {
|
|
130
144
|
createOrUpdateProperty: createOrUpdateProperty,
|
|
131
145
|
getDocPropsProperties: getDocPropsProperties,
|
|
132
146
|
getCellReferenceRelative: getCellReferenceRelative,
|
|
@@ -135,4 +149,5 @@ export default {
|
|
|
135
149
|
getTableReference: getTableReference,
|
|
136
150
|
updateCellData: updateCellData,
|
|
137
151
|
resolveType: resolveType,
|
|
152
|
+
convertToExcelColumn: convertToExcelColumn,
|
|
138
153
|
};
|
package/dist/utils/gridUtils.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// Copyright (c) Microsoft Corporation.
|
|
2
3
|
// Licensed under the MIT license.
|
|
3
|
-
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
var constants_1 = require("../utils/constants");
|
|
4
6
|
var parseToTableData = function (grid) {
|
|
5
7
|
var _a, _b, _c, _d;
|
|
6
8
|
if (grid === null || grid === undefined) {
|
|
@@ -27,7 +29,7 @@ var parseToTableData = function (grid) {
|
|
|
27
29
|
columnNames = mergedGrid.data.shift();
|
|
28
30
|
}
|
|
29
31
|
else {
|
|
30
|
-
columnNames = Array.from({ length: mergedGrid.data[0].length }, function (_, index) { return "".concat(defaults.columnName, " ").concat(index + 1); });
|
|
32
|
+
columnNames = Array.from({ length: mergedGrid.data[0].length }, function (_, index) { return "".concat(constants_1.defaults.columnName, " ").concat(index + 1); });
|
|
31
33
|
}
|
|
32
34
|
return { columnNames: columnNames, rows: mergedGrid.data };
|
|
33
35
|
};
|
|
@@ -62,15 +64,15 @@ var correctGrid = function (grid) {
|
|
|
62
64
|
var validateGrid = function (grid) {
|
|
63
65
|
validateDataArrayDimensions(grid.data);
|
|
64
66
|
if (grid.config.promoteHeaders && grid.config.adjustColumnNames === false && !validateUniqueAndValidDataArray(grid.data[0])) {
|
|
65
|
-
throw new Error(promotedHeadersCannotBeUsedWithoutAdjustingColumnNamesErr);
|
|
67
|
+
throw new Error(constants_1.promotedHeadersCannotBeUsedWithoutAdjustingColumnNamesErr);
|
|
66
68
|
}
|
|
67
69
|
};
|
|
68
70
|
var validateDataArrayDimensions = function (arr) {
|
|
69
71
|
if (arr.length === 0 || arr[0].length === 0) {
|
|
70
|
-
throw new Error(unexpectedErr);
|
|
72
|
+
throw new Error(constants_1.unexpectedErr);
|
|
71
73
|
}
|
|
72
74
|
if (!arr.every(function (innerArr) { return innerArr.length === arr[0].length; })) {
|
|
73
|
-
throw new Error(arrayIsntMxNErr);
|
|
75
|
+
throw new Error(constants_1.arrayIsntMxNErr);
|
|
74
76
|
}
|
|
75
77
|
};
|
|
76
78
|
var validateUniqueAndValidDataArray = function (arr) {
|
|
@@ -82,11 +84,11 @@ var validateUniqueAndValidDataArray = function (arr) {
|
|
|
82
84
|
};
|
|
83
85
|
var getAdjustedColumnNames = function (columnNames) {
|
|
84
86
|
if (columnNames === undefined) {
|
|
85
|
-
throw new Error(unexpectedErr);
|
|
87
|
+
throw new Error(constants_1.unexpectedErr);
|
|
86
88
|
}
|
|
87
89
|
var i = 1;
|
|
88
90
|
// replace empty column names with default names, can still conflict if columns exist, but we handle that later
|
|
89
|
-
columnNames = columnNames.map(function (columnName) { return columnName || "".concat(defaults.columnName, " ").concat(i++); });
|
|
91
|
+
columnNames = columnNames.map(function (columnName) { return columnName || "".concat(constants_1.defaults.columnName, " ").concat(i++); });
|
|
90
92
|
var uniqueNames = new Set();
|
|
91
93
|
return columnNames.map(function (name) {
|
|
92
94
|
var uniqueName = name;
|
|
@@ -98,4 +100,4 @@ var getAdjustedColumnNames = function (columnNames) {
|
|
|
98
100
|
return uniqueName;
|
|
99
101
|
});
|
|
100
102
|
};
|
|
101
|
-
|
|
103
|
+
exports.default = { parseToTableData: parseToTableData };
|
package/dist/utils/htmlUtils.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// Copyright (c) Microsoft Corporation.
|
|
2
3
|
// Licensed under the MIT license.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
5
|
var extractTableValues = function (table) {
|
|
4
6
|
var rows = [];
|
|
5
7
|
// Extract values from each row
|
|
@@ -14,4 +16,4 @@ var extractTableValues = function (table) {
|
|
|
14
16
|
}
|
|
15
17
|
return rows;
|
|
16
18
|
};
|
|
17
|
-
|
|
19
|
+
exports.default = { extractTableValues: extractTableValues };
|
package/dist/utils/index.js
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// Copyright (c) Microsoft Corporation.
|
|
2
3
|
// Licensed under the MIT license.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.gridUtils = exports.htmlUtils = exports.tableUtils = exports.xmlInnerPartsUtils = exports.xmlPartsUtils = exports.documentUtils = exports.arrayUtils = exports.pqUtils = void 0;
|
|
9
|
+
var pqUtils_1 = require("./pqUtils");
|
|
10
|
+
Object.defineProperty(exports, "pqUtils", { enumerable: true, get: function () { return __importDefault(pqUtils_1).default; } });
|
|
11
|
+
var arrayUtils_1 = require("./arrayUtils");
|
|
12
|
+
Object.defineProperty(exports, "arrayUtils", { enumerable: true, get: function () { return __importDefault(arrayUtils_1).default; } });
|
|
13
|
+
var documentUtils_1 = require("./documentUtils");
|
|
14
|
+
Object.defineProperty(exports, "documentUtils", { enumerable: true, get: function () { return __importDefault(documentUtils_1).default; } });
|
|
15
|
+
var xmlPartsUtils_1 = require("./xmlPartsUtils");
|
|
16
|
+
Object.defineProperty(exports, "xmlPartsUtils", { enumerable: true, get: function () { return __importDefault(xmlPartsUtils_1).default; } });
|
|
17
|
+
var xmlInnerPartsUtils_1 = require("./xmlInnerPartsUtils");
|
|
18
|
+
Object.defineProperty(exports, "xmlInnerPartsUtils", { enumerable: true, get: function () { return __importDefault(xmlInnerPartsUtils_1).default; } });
|
|
19
|
+
var tableUtils_1 = require("./tableUtils");
|
|
20
|
+
Object.defineProperty(exports, "tableUtils", { enumerable: true, get: function () { return __importDefault(tableUtils_1).default; } });
|
|
21
|
+
var htmlUtils_1 = require("./htmlUtils");
|
|
22
|
+
Object.defineProperty(exports, "htmlUtils", { enumerable: true, get: function () { return __importDefault(htmlUtils_1).default; } });
|
|
23
|
+
var gridUtils_1 = require("./gridUtils");
|
|
24
|
+
Object.defineProperty(exports, "gridUtils", { enumerable: true, get: function () { return __importDefault(gridUtils_1).default; } });
|