@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.
Files changed (37) hide show
  1. package/dist/utils/constants.js +87 -49
  2. package/dist/utils/documentUtils.js +1 -1
  3. package/dist/utils/gridUtils.js +8 -8
  4. package/dist/utils/mashupDocumentParser.js +1 -1
  5. package/dist/utils/pqUtils.js +3 -3
  6. package/dist/utils/tableUtils.js +11 -4
  7. package/dist/utils/xmlInnerPartsUtils.js +245 -13
  8. package/dist/utils/xmlPartsUtils.js +74 -4
  9. package/dist/workbookManager.js +3 -3
  10. package/package.json +7 -3
  11. package/dist/src/generators.js +0 -15
  12. package/dist/src/types.js +0 -28
  13. package/dist/src/utils/arrayUtils.js +0 -51
  14. package/dist/src/utils/constants.js +0 -175
  15. package/dist/src/utils/documentUtils.js +0 -167
  16. package/dist/src/utils/gridUtils.js +0 -103
  17. package/dist/src/utils/htmlUtils.js +0 -19
  18. package/dist/src/utils/index.js +0 -24
  19. package/dist/src/utils/mashupDocumentParser.js +0 -188
  20. package/dist/src/utils/pqUtils.js +0 -194
  21. package/dist/src/utils/tableUtils.js +0 -233
  22. package/dist/src/utils/xmlInnerPartsUtils.js +0 -431
  23. package/dist/src/utils/xmlPartsUtils.js +0 -178
  24. package/dist/src/workbookTemplate.js +0 -9
  25. package/dist/tests/arrayUtils.test.js +0 -66
  26. package/dist/tests/documentUtils.test.js +0 -70
  27. package/dist/tests/gridUtils.test.js +0 -214
  28. package/dist/tests/htmlUtils.test.js +0 -111
  29. package/dist/tests/mashupDocumentParser.test.js +0 -113
  30. package/dist/tests/mocks/PqMock.js +0 -7
  31. package/dist/tests/mocks/index.js +0 -24
  32. package/dist/tests/mocks/section1mSimpleQueryMock.js +0 -8
  33. package/dist/tests/mocks/xmlMocks.js +0 -14
  34. package/dist/tests/tableUtils.test.js +0 -70
  35. package/dist/tests/workbookQueryTemplate.test.js +0 -218
  36. package/dist/tests/workbookTableTemplate.test.js +0 -126
  37. package/dist/tests/xmlInnerPartsUtils.test.js +0 -273
@@ -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
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.textResultType = exports.application = exports.uint8ArrayType = exports.blobFileType = exports.relationshipErr = exports.columnIndexOutOfRangeErr = exports.xlRelsNotFoundErr = 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.tableReferenceNotFoundErr = exports.tableNotFoundErr = exports.queryTableNotFoundErr = exports.templateWithInitialDataErr = exports.formulaSectionNotFoundErr = exports.queryConnectionNotFoundErr = exports.queryAndPivotTableNotFoundErr = exports.queryNameNotFoundErr = exports.emptyQueryMashupErr = exports.base64NotFoundErr = exports.sheetsNotFoundErr = exports.WorkbookNotFoundERR = exports.connectionsNotFoundErr = exports.sharedStringsNotFoundErr = 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 = 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 = exports.maxQueryLength = exports.divider = exports.section1PathPrefix = exports.emptyValue = exports.falseValue = exports.trueValue = exports.pivotCachesPathPrefix = exports.xmlTextResultType = void 0;
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.sharedStringsNotFoundErr = "SharedStrings were not found in template";
25
- exports.connectionsNotFoundErr = "Connections were not found in template";
26
- exports.WorkbookNotFoundERR = "workbook was not found in template";
27
- exports.sheetsNotFoundErr = "Sheets were not found in template";
28
- exports.base64NotFoundErr = "Base64 was not found in template";
29
- exports.emptyQueryMashupErr = "Query mashup is empty";
30
- exports.queryNameNotFoundErr = "Query name was not found";
31
- exports.queryAndPivotTableNotFoundErr = "No such query found in Query Table or Pivot Table found in given template";
32
- exports.queryConnectionNotFoundErr = "No connection found for query";
33
- exports.formulaSectionNotFoundErr = "Formula section wasn't found in template";
34
- exports.templateWithInitialDataErr = "Cannot use a template file with initial data";
35
- exports.queryTableNotFoundErr = "Query table wasn't found in template";
36
- exports.tableNotFoundErr = "Table wasn't found in template";
37
- exports.tableReferenceNotFoundErr = "Reference not found in the table XML.";
38
- exports.invalidValueInColumnErr = "Invalid cell value in column";
39
- exports.headerNotFoundErr = "Invalid JSON file, header is missing";
40
- exports.invalidDataTypeErr = "Invalid JSON file, invalid data type";
41
- exports.QueryNameMaxLengthErr = "Query names are limited to 80 characters";
42
- exports.QueryNameInvalidCharsErr = 'Query names cannot contain periods or quotation marks. (. ")';
43
- exports.EmptyQueryNameErr = "Query name cannot be empty";
44
- exports.stylesNotFoundErr = "Styles were not found in template";
45
- exports.InvalidColumnNameErr = "Invalid column name";
46
- exports.promotedHeadersCannotBeUsedWithoutAdjustingColumnNamesErr = "Headers cannot be promoted without adjusting column names";
47
- exports.unexpectedErr = "Unexpected error";
48
- exports.arrayIsntMxNErr = "Array isn't MxN";
49
- exports.relsNotFoundErr = ".rels were not found in template";
50
- exports.xlRelsNotFoundErr = "workbook.xml.rels were not found xl";
51
- exports.columnIndexOutOfRangeErr = "Column index out of range";
52
- exports.relationshipErr = "Relationship not found";
53
- exports.blobFileType = "blob";
54
- exports.uint8ArrayType = "uint8array";
55
- exports.application = "application/xlsx";
56
- exports.textResultType = "text";
57
- exports.xmlTextResultType = "text/xml";
58
- exports.pivotCachesPathPrefix = "pivotCacheDefinition";
59
- exports.trueValue = "1";
60
- exports.falseValue = "0";
61
- exports.emptyValue = "";
62
- exports.section1PathPrefix = "Section1/";
63
- exports.divider = "/";
64
- exports.maxQueryLength = 80;
65
- exports.trueStr = "true";
66
- exports.falseStr = "false";
67
- exports.BOM = "\ufeff";
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.columnIndexOutOfRangeErr);
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
@@ -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.promotedHeadersCannotBeUsedWithoutAdjustingColumnNamesErr);
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.unexpectedErr);
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.arrayIsntMxNErr);
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.unexpectedErr);
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.formulaSectionNotFoundErr);
129
+ throw new Error(constants_1.Errors.formulaSectionNotFound);
130
130
  }
131
131
  var newSection1m = queryMashupDoc;
132
132
  zip.file(constants_1.section1mPath, newSection1m, {
@@ -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.QueryNameMaxLengthErr);
162
+ throw new Error(constants_1.Errors.queryNameMaxLength);
163
163
  }
164
164
  if (queryNameHasInvalidChars(queryName)) {
165
- throw new Error(constants_1.QueryNameInvalidCharsErr);
165
+ throw new Error(constants_1.Errors.queryNameInvalidChars);
166
166
  }
167
167
  }
168
168
  if (!queryName.trim()) {
169
- throw new Error(constants_1.EmptyQueryNameErr);
169
+ throw new Error(constants_1.Errors.emptyQueryName);
170
170
  }
171
171
  };
172
172
  var detectEncoding = function (xmlBytes) {
@@ -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.sheetsNotFoundErr);
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.queryTableNotFoundErr);
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.sheetsNotFoundErr);
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.tableNotFoundErr);
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".