@microsoft/connected-workbooks 3.3.2-beta → 3.4.0
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/utils/constants.js +87 -49
- package/dist/utils/documentUtils.js +1 -1
- package/dist/utils/gridUtils.js +8 -8
- package/dist/utils/mashupDocumentParser.js +1 -1
- package/dist/utils/pqUtils.js +3 -3
- package/dist/utils/tableUtils.js +11 -4
- package/dist/utils/xmlInnerPartsUtils.js +245 -13
- package/dist/utils/xmlPartsUtils.js +74 -4
- package/dist/workbookManager.js +3 -3
- package/package.json +7 -3
- package/dist/src/generators.js +0 -15
- package/dist/src/types.js +0 -28
- package/dist/src/utils/arrayUtils.js +0 -51
- package/dist/src/utils/constants.js +0 -175
- package/dist/src/utils/documentUtils.js +0 -167
- package/dist/src/utils/gridUtils.js +0 -103
- package/dist/src/utils/htmlUtils.js +0 -19
- package/dist/src/utils/index.js +0 -24
- package/dist/src/utils/mashupDocumentParser.js +0 -188
- package/dist/src/utils/pqUtils.js +0 -194
- package/dist/src/utils/tableUtils.js +0 -233
- package/dist/src/utils/xmlInnerPartsUtils.js +0 -431
- package/dist/src/utils/xmlPartsUtils.js +0 -178
- package/dist/src/workbookTemplate.js +0 -9
- package/dist/tests/arrayUtils.test.js +0 -66
- package/dist/tests/documentUtils.test.js +0 -70
- package/dist/tests/gridUtils.test.js +0 -214
- package/dist/tests/htmlUtils.test.js +0 -111
- package/dist/tests/mashupDocumentParser.test.js +0 -113
- package/dist/tests/mocks/PqMock.js +0 -7
- package/dist/tests/mocks/index.js +0 -24
- package/dist/tests/mocks/section1mSimpleQueryMock.js +0 -8
- package/dist/tests/mocks/xmlMocks.js +0 -14
- package/dist/tests/tableUtils.test.js +0 -70
- package/dist/tests/workbookQueryTemplate.test.js +0 -218
- package/dist/tests/workbookTableTemplate.test.js +0 -126
- package/dist/tests/xmlInnerPartsUtils.test.js +0 -273
package/dist/utils/constants.js
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.customXML = exports.OFU = exports.headers = exports.URLS = exports.defaults = exports.elementAttributesValues = exports.dataTypeKind = exports.elementAttributes = exports.element = exports.Errors = exports.customXmlXmlPath = exports.contentTypesXmlPath = exports.docPropsAppXmlPath = exports.labelInfoXmlPath = exports.workbookRelsXmlPath = exports.docPropsRootElement = exports.docMetadataXmlPath = exports.relsXmlPath = exports.docPropsCoreXmlPath = exports.section1mPath = exports.pivotCachesPath = exports.tablesFolderPath = exports.queryTablesPath = exports.workbookXmlPath = exports.queryTableXmlPath = exports.tableXmlPath = exports.sheetsXmlPath = exports.sharedStringsXmlPath = exports.connectionsXmlPath = exports.maxCellCharacters = 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 = void 0;
|
|
2
4
|
// Copyright (c) Microsoft Corporation.
|
|
3
5
|
// Licensed under the MIT license.
|
|
4
|
-
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
6
|
+
exports.blobFileType = "blob";
|
|
7
|
+
exports.uint8ArrayType = "uint8array";
|
|
8
|
+
exports.application = "application/xlsx";
|
|
9
|
+
exports.textResultType = "text";
|
|
10
|
+
exports.xmlTextResultType = "text/xml";
|
|
11
|
+
exports.pivotCachesPathPrefix = "pivotCacheDefinition";
|
|
12
|
+
exports.trueValue = "1";
|
|
13
|
+
exports.falseValue = "0";
|
|
14
|
+
exports.emptyValue = "";
|
|
15
|
+
exports.section1PathPrefix = "Section1/";
|
|
16
|
+
exports.divider = "/";
|
|
17
|
+
exports.maxQueryLength = 80;
|
|
18
|
+
exports.trueStr = "true";
|
|
19
|
+
exports.falseStr = "false";
|
|
20
|
+
exports.BOM = "\ufeff";
|
|
21
|
+
exports.maxCellCharacters = 32767;
|
|
7
22
|
exports.connectionsXmlPath = "xl/connections.xml";
|
|
8
23
|
exports.sharedStringsXmlPath = "xl/sharedStrings.xml";
|
|
9
24
|
exports.sheetsXmlPath = "xl/worksheets/sheet1.xml";
|
|
@@ -21,50 +36,54 @@ exports.docPropsRootElement = "cp:coreProperties";
|
|
|
21
36
|
exports.workbookRelsXmlPath = "xl/_rels/workbook.xml.rels";
|
|
22
37
|
exports.labelInfoXmlPath = "docMetadata/LabelInfo.xml";
|
|
23
38
|
exports.docPropsAppXmlPath = "docProps/app.xml";
|
|
24
|
-
exports.
|
|
25
|
-
exports.
|
|
26
|
-
exports.
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
39
|
+
exports.contentTypesXmlPath = "[Content_Types].xml";
|
|
40
|
+
exports.customXmlXmlPath = "customXml";
|
|
41
|
+
exports.Errors = {
|
|
42
|
+
sharedStringsNotFound: "SharedStrings were not found in template",
|
|
43
|
+
connectionsNotFound: "Connections were not found in template",
|
|
44
|
+
workbookNotFound: "workbook was not found in template",
|
|
45
|
+
sheetsNotFound: "Sheets were not found in template",
|
|
46
|
+
base64NotFound: "Base64 was not found in template",
|
|
47
|
+
emptyQueryMashup: "Query mashup is empty",
|
|
48
|
+
queryNameNotFound: "Query name was not found",
|
|
49
|
+
queryAndPivotTableNotFound: "No such query found in Query Table or Pivot Table found in given template",
|
|
50
|
+
queryConnectionNotFound: "No connection found for query",
|
|
51
|
+
formulaSectionNotFound: "Formula section wasn't found in template",
|
|
52
|
+
templateWithInitialData: "Cannot use a template file with initial data",
|
|
53
|
+
queryTableNotFound: "Query table wasn't found in template",
|
|
54
|
+
tableNotFound: "Table wasn't found in template",
|
|
55
|
+
tableReferenceNotFound: "Reference not found in the table XML.",
|
|
56
|
+
invalidValueInColumn: "Invalid cell value in column",
|
|
57
|
+
headerNotFound: "Invalid JSON file, header is missing",
|
|
58
|
+
invalidDataType: "Invalid JSON file, invalid data type",
|
|
59
|
+
queryNameMaxLength: "Query names are limited to 80 characters",
|
|
60
|
+
queryNameInvalidChars: 'Query names cannot contain periods or quotation marks. (. ")',
|
|
61
|
+
emptyQueryName: "Query name cannot be empty",
|
|
62
|
+
stylesNotFound: "Styles were not found in template",
|
|
63
|
+
invalidColumnName: "Invalid column name",
|
|
64
|
+
promotedHeadersCannotBeUsedWithoutAdjustingColumnNames: "Headers cannot be promoted without adjusting column names",
|
|
65
|
+
unexpected: "Unexpected error",
|
|
66
|
+
arrayIsntMxN: "Array isn't MxN",
|
|
67
|
+
relsNotFound: ".rels were not found in template",
|
|
68
|
+
xlRelsNotFound: "workbook.xml.rels were not found xl",
|
|
69
|
+
columnIndexOutOfRange: "Column index out of range",
|
|
70
|
+
relationship: "Relationship not found",
|
|
71
|
+
contentTypesNotFound: "contentTypes was not found in file",
|
|
72
|
+
contentTypesParse: "Failed to parse [Content_Types].xml: Invalid XML structure",
|
|
73
|
+
contentTypesElementNotFound: "contentTypes element was not found in parsed document",
|
|
74
|
+
workbookRelsParse: "Failed to parse workbook relationships XML: Invalid XML structure",
|
|
75
|
+
xmlParse: "Failed to parse XML: Parser error detected",
|
|
76
|
+
relsParse: "Failed to parse .rels XML",
|
|
77
|
+
connectionsParse: "Failed to parse connections XML",
|
|
78
|
+
sharedStringsParse: "Failed to parse shared strings XML",
|
|
79
|
+
worksheetParse: "Failed to parse worksheet XML",
|
|
80
|
+
queryTableParse: "Failed to parse query table XML",
|
|
81
|
+
pivotTableParse: "Failed to parse pivot table XML",
|
|
82
|
+
workbookParse: "Failed to parse workbook XML",
|
|
83
|
+
tableParse: "Failed to parse table XML",
|
|
84
|
+
tablePathParse: "Failed to parse table XML for",
|
|
85
|
+
invalidCellValueErr: "Cell content exceeds maximum length of " + exports.maxCellCharacters + " characters",
|
|
86
|
+
};
|
|
68
87
|
exports.element = {
|
|
69
88
|
sharedStringTable: "sst",
|
|
70
89
|
text: "t",
|
|
@@ -94,8 +113,9 @@ exports.element = {
|
|
|
94
113
|
selection: "selection",
|
|
95
114
|
kindCell: "c",
|
|
96
115
|
sheet: "sheet",
|
|
116
|
+
override: "Override",
|
|
117
|
+
relationship: "Relationship",
|
|
97
118
|
relationships: "Relationships",
|
|
98
|
-
relationship: "Relationship"
|
|
99
119
|
};
|
|
100
120
|
exports.elementAttributes = {
|
|
101
121
|
connection: "connection",
|
|
@@ -134,6 +154,9 @@ exports.elementAttributes = {
|
|
|
134
154
|
xr3uid: "xr3:uid",
|
|
135
155
|
space: "xml:space",
|
|
136
156
|
target: "Target",
|
|
157
|
+
partName: "PartName",
|
|
158
|
+
contentType: "ContentType",
|
|
159
|
+
relationshipIdPrefix: "rId",
|
|
137
160
|
};
|
|
138
161
|
exports.dataTypeKind = {
|
|
139
162
|
string: "str",
|
|
@@ -144,7 +167,7 @@ exports.elementAttributesValues = {
|
|
|
144
167
|
connectionName: function (queryName) { return "Query - ".concat(queryName); },
|
|
145
168
|
connectionDescription: function (queryName) { return "Connection to the '".concat(queryName, "' query in the workbook."); },
|
|
146
169
|
connection: function (queryName) { return "Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=\"".concat(queryName, "\";"); },
|
|
147
|
-
connectionCommand: function (queryName) { return "SELECT * FROM [".concat(queryName, "]"); },
|
|
170
|
+
connectionCommand: function (queryName) { return "SELECT * FROM [".concat(queryName.replace(/]/g, ']]'), "]"); },
|
|
148
171
|
tableResultType: function () { return "sTable"; },
|
|
149
172
|
};
|
|
150
173
|
exports.defaults = {
|
|
@@ -173,3 +196,18 @@ exports.OFU = {
|
|
|
173
196
|
WdOrigin: "wdOrigin",
|
|
174
197
|
OpenInExcelOririgin: "OpenInExcel",
|
|
175
198
|
};
|
|
199
|
+
exports.customXML = {
|
|
200
|
+
customXMLItemContent: "<?xml version=\"1.0\" encoding=\"utf-8\"?><ConnectedWorkbook xmlns=\"http://schemas.microsoft.com/ConnectedWorkbook\" version=\"1.0.0\"></ConnectedWorkbook>",
|
|
201
|
+
customXMLItemPropsContent: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<ds:datastoreItem ds:itemID=\"{0B384C3C-E1D4-401B-8CF4-6285949D7671}\" xmlns:ds=\"http://schemas.openxmlformats.org/officeDocument/2006/customXml\"><ds:schemaRefs><ds:schemaRef ds:uri=\"http://schemas.microsoft.com/ConnectedWorkbook\"/></ds:schemaRefs></ds:datastoreItem>",
|
|
202
|
+
connectedWorkbookTag: '<ConnectedWorkbook',
|
|
203
|
+
itemNumberPattern: /item(\d+)\.xml$/,
|
|
204
|
+
itemFilePattern: /^item\d+\.xml$/,
|
|
205
|
+
itemPropsPartNameTemplate: function (itemIndex) { return "/customXml/itemProps".concat(itemIndex, ".xml"); },
|
|
206
|
+
contentType: "application/vnd.openxmlformats-officedocument.customXmlProperties+xml",
|
|
207
|
+
itemPathTemplate: function (itemNumber) { return "customXml/item".concat(itemNumber, ".xml"); },
|
|
208
|
+
itemPropsPathTemplate: function (itemNumber) { return "customXml/itemProps".concat(itemNumber, ".xml"); },
|
|
209
|
+
itemRelsPathTemplate: function (itemNumber) { return "customXml/_rels/item".concat(itemNumber, ".xml.rels"); },
|
|
210
|
+
customXMLRelationships: function (itemNumber) { return "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\"><Relationship Id=\"rId1\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps\" Target=\"itemProps".concat(itemNumber, ".xml\"/></Relationships>"); },
|
|
211
|
+
relationshipType: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml",
|
|
212
|
+
relativeItemPathTemplate: function (itemNumber) { return "../customXml/item".concat(itemNumber, ".xml"); },
|
|
213
|
+
};
|
|
@@ -87,7 +87,7 @@ var getCellReferenceRelative = function (col, row) {
|
|
|
87
87
|
};
|
|
88
88
|
var convertToExcelColumn = function (index) {
|
|
89
89
|
if (index >= 16384) {
|
|
90
|
-
throw new Error(constants_1.
|
|
90
|
+
throw new Error(constants_1.Errors.columnIndexOutOfRange);
|
|
91
91
|
}
|
|
92
92
|
var columnStr = "";
|
|
93
93
|
var base = 26; // number of letters in the alphabet
|
package/dist/utils/gridUtils.js
CHANGED
|
@@ -64,27 +64,27 @@ var correctGrid = function (grid) {
|
|
|
64
64
|
var validateGrid = function (grid) {
|
|
65
65
|
validateDataArrayDimensions(grid.data);
|
|
66
66
|
if (grid.config.promoteHeaders && grid.config.adjustColumnNames === false && !validateUniqueAndValidDataArray(grid.data[0])) {
|
|
67
|
-
throw new Error(constants_1.
|
|
67
|
+
throw new Error(constants_1.Errors.promotedHeadersCannotBeUsedWithoutAdjustingColumnNames);
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
var validateDataArrayDimensions = function (arr) {
|
|
71
71
|
if (arr.length === 0 || arr[0].length === 0) {
|
|
72
|
-
throw new Error(constants_1.
|
|
72
|
+
throw new Error(constants_1.Errors.unexpected);
|
|
73
73
|
}
|
|
74
74
|
if (!arr.every(function (innerArr) { return innerArr.length === arr[0].length; })) {
|
|
75
|
-
throw new Error(constants_1.
|
|
75
|
+
throw new Error(constants_1.Errors.arrayIsntMxN);
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
78
|
var validateUniqueAndValidDataArray = function (arr) {
|
|
79
79
|
if (arr.some(function (element) { return element === ""; })) {
|
|
80
80
|
return false; // Array contains empty elements
|
|
81
81
|
}
|
|
82
|
-
var uniqueSet = new Set(arr);
|
|
82
|
+
var uniqueSet = new Set(arr.map(function (item) { return item.toLowerCase(); }));
|
|
83
83
|
return uniqueSet.size === arr.length;
|
|
84
84
|
};
|
|
85
85
|
var getAdjustedColumnNames = function (columnNames) {
|
|
86
86
|
if (columnNames === undefined) {
|
|
87
|
-
throw new Error(constants_1.
|
|
87
|
+
throw new Error(constants_1.Errors.unexpected);
|
|
88
88
|
}
|
|
89
89
|
var i = 1;
|
|
90
90
|
// replace empty column names with default names, can still conflict if columns exist, but we handle that later
|
|
@@ -93,11 +93,11 @@ var getAdjustedColumnNames = function (columnNames) {
|
|
|
93
93
|
return columnNames.map(function (name) {
|
|
94
94
|
var uniqueName = name;
|
|
95
95
|
i = 1;
|
|
96
|
-
while (uniqueNames.has(uniqueName)) {
|
|
96
|
+
while (uniqueNames.has(uniqueName.toLowerCase())) {
|
|
97
97
|
uniqueName = "".concat(name, " (").concat(i++, ")");
|
|
98
98
|
}
|
|
99
|
-
uniqueNames.add(uniqueName);
|
|
99
|
+
uniqueNames.add(uniqueName.toLowerCase());
|
|
100
100
|
return uniqueName;
|
|
101
101
|
});
|
|
102
102
|
};
|
|
103
|
-
exports.default = { parseToTableData: parseToTableData };
|
|
103
|
+
exports.default = { parseToTableData: parseToTableData, validateUniqueAndValidDataArray: validateUniqueAndValidDataArray };
|
|
@@ -126,7 +126,7 @@ var editSingleQueryPackage = function (packageOPC, queryMashupDoc) { return __aw
|
|
|
126
126
|
var setSection1m = function (queryMashupDoc, zip) {
|
|
127
127
|
var _a;
|
|
128
128
|
if (!((_a = zip.file(constants_1.section1mPath)) === null || _a === void 0 ? void 0 : _a.async(constants_1.textResultType))) {
|
|
129
|
-
throw new Error(constants_1.
|
|
129
|
+
throw new Error(constants_1.Errors.formulaSectionNotFound);
|
|
130
130
|
}
|
|
131
131
|
var newSection1m = queryMashupDoc;
|
|
132
132
|
zip.file(constants_1.section1mPath, newSection1m, {
|
package/dist/utils/pqUtils.js
CHANGED
|
@@ -159,14 +159,14 @@ var queryNameHasInvalidChars = function (queryName) {
|
|
|
159
159
|
var validateQueryName = function (queryName) {
|
|
160
160
|
if (queryName) {
|
|
161
161
|
if (queryName.length > constants_1.maxQueryLength) {
|
|
162
|
-
throw new Error(constants_1.
|
|
162
|
+
throw new Error(constants_1.Errors.queryNameMaxLength);
|
|
163
163
|
}
|
|
164
164
|
if (queryNameHasInvalidChars(queryName)) {
|
|
165
|
-
throw new Error(constants_1.
|
|
165
|
+
throw new Error(constants_1.Errors.queryNameInvalidChars);
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
if (!queryName.trim()) {
|
|
169
|
-
throw new Error(constants_1.
|
|
169
|
+
throw new Error(constants_1.Errors.emptyQueryName);
|
|
170
170
|
}
|
|
171
171
|
};
|
|
172
172
|
var detectEncoding = function (xmlBytes) {
|
package/dist/utils/tableUtils.js
CHANGED
|
@@ -68,7 +68,7 @@ var updateTableInitialDataIfNeeded = function (zip, cellRangeRef, sheetPath, tab
|
|
|
68
68
|
case 1:
|
|
69
69
|
sheetsXmlString = _e.sent();
|
|
70
70
|
if (sheetsXmlString === undefined) {
|
|
71
|
-
throw new Error(constants_1.
|
|
71
|
+
throw new Error(constants_1.Errors.sheetsNotFound);
|
|
72
72
|
}
|
|
73
73
|
newSheet = updateSheetsInitialData(sheetsXmlString, tableData, cellRangeRef);
|
|
74
74
|
zip.file(sheetPath, newSheet);
|
|
@@ -77,7 +77,7 @@ var updateTableInitialDataIfNeeded = function (zip, cellRangeRef, sheetPath, tab
|
|
|
77
77
|
case 2:
|
|
78
78
|
queryTableXmlString = _e.sent();
|
|
79
79
|
if (queryTableXmlString === undefined) {
|
|
80
|
-
throw new Error(constants_1.
|
|
80
|
+
throw new Error(constants_1.Errors.queryTableNotFound);
|
|
81
81
|
}
|
|
82
82
|
return [4 /*yield*/, updateQueryTablesInitialData(queryTableXmlString, tableData)];
|
|
83
83
|
case 3:
|
|
@@ -87,7 +87,7 @@ var updateTableInitialDataIfNeeded = function (zip, cellRangeRef, sheetPath, tab
|
|
|
87
87
|
case 4:
|
|
88
88
|
workbookXmlString = _e.sent();
|
|
89
89
|
if (workbookXmlString === undefined) {
|
|
90
|
-
throw new Error(constants_1.
|
|
90
|
+
throw new Error(constants_1.Errors.workbookNotFound);
|
|
91
91
|
}
|
|
92
92
|
newWorkbook = updateWorkbookInitialData(workbookXmlString, sheetName + GenerateReferenceFromString(cellRangeRef));
|
|
93
93
|
zip.file(constants_1.workbookXmlPath, newWorkbook);
|
|
@@ -96,7 +96,7 @@ var updateTableInitialDataIfNeeded = function (zip, cellRangeRef, sheetPath, tab
|
|
|
96
96
|
case 6:
|
|
97
97
|
tableXmlString = _e.sent();
|
|
98
98
|
if (tableXmlString === undefined) {
|
|
99
|
-
throw new Error(constants_1.
|
|
99
|
+
throw new Error(constants_1.Errors.tableNotFound);
|
|
100
100
|
}
|
|
101
101
|
newTable = updateTablesInitialData(tableXmlString, tableData, cellRangeRef, updateQueryTable);
|
|
102
102
|
zip.file(tablePath, newTable);
|
|
@@ -189,6 +189,7 @@ var updateSheetsInitialData = function (sheetsXmlString, tableData, cellRangeRef
|
|
|
189
189
|
columnRow.setAttribute(constants_1.elementAttributes.spans, column + ":" + (column + tableData.columnNames.length - 1));
|
|
190
190
|
columnRow.setAttribute(constants_1.elementAttributes.x14acDyDescent, "0.3");
|
|
191
191
|
tableData.columnNames.forEach(function (col, colIndex) {
|
|
192
|
+
validateCellContentLength(col);
|
|
192
193
|
columnRow.appendChild(documentUtils_1.default.createCell(sheetsDoc, colIndex + column - 1, row - 1, col));
|
|
193
194
|
});
|
|
194
195
|
sheetData.appendChild(columnRow);
|
|
@@ -199,6 +200,7 @@ var updateSheetsInitialData = function (sheetsXmlString, tableData, cellRangeRef
|
|
|
199
200
|
newRow.setAttribute(constants_1.elementAttributes.spans, column + ":" + (column + tableData.columnNames.length - 1));
|
|
200
201
|
newRow.setAttribute(constants_1.elementAttributes.x14acDyDescent, "0.3");
|
|
201
202
|
_row.forEach(function (cellContent, colIndex) {
|
|
203
|
+
validateCellContentLength(cellContent);
|
|
202
204
|
newRow.appendChild(documentUtils_1.default.createCell(sheetsDoc, colIndex + column - 1, row - 1, cellContent));
|
|
203
205
|
});
|
|
204
206
|
sheetData.appendChild(newRow);
|
|
@@ -208,6 +210,11 @@ var updateSheetsInitialData = function (sheetsXmlString, tableData, cellRangeRef
|
|
|
208
210
|
sheetsDoc.getElementsByTagName(constants_1.element.selection)[0].setAttribute(constants_1.elementAttributes.sqref, cellRangeRef);
|
|
209
211
|
return serializer.serializeToString(sheetsDoc);
|
|
210
212
|
};
|
|
213
|
+
var validateCellContentLength = function (cellContent) {
|
|
214
|
+
if (cellContent.length > constants_1.maxCellCharacters) {
|
|
215
|
+
throw new Error(constants_1.Errors.invalidCellValueErr);
|
|
216
|
+
}
|
|
217
|
+
};
|
|
211
218
|
/**
|
|
212
219
|
* Add Excel-style dollar signs and a '!' prefix to a cell range.
|
|
213
220
|
* Converts "A1:B2" into "!$A$1:$B$2".
|