@microsoft/connected-workbooks 3.3.1-beta → 3.4.0-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.
Files changed (40) hide show
  1. package/README.md +3 -3
  2. package/dist/types.d.ts +2 -1
  3. package/dist/utils/constants.js +94 -47
  4. package/dist/utils/documentUtils.js +2 -2
  5. package/dist/utils/gridUtils.js +4 -4
  6. package/dist/utils/mashupDocumentParser.js +1 -1
  7. package/dist/utils/pqUtils.js +3 -3
  8. package/dist/utils/tableUtils.js +11 -4
  9. package/dist/utils/xmlInnerPartsUtils.js +294 -31
  10. package/dist/utils/xmlPartsUtils.js +93 -19
  11. package/dist/workbookManager.js +3 -3
  12. package/dist/workbookTemplate.js +2 -1
  13. package/package.json +5 -3
  14. package/dist/src/generators.js +0 -15
  15. package/dist/src/types.js +0 -28
  16. package/dist/src/utils/arrayUtils.js +0 -51
  17. package/dist/src/utils/constants.js +0 -166
  18. package/dist/src/utils/documentUtils.js +0 -167
  19. package/dist/src/utils/gridUtils.js +0 -103
  20. package/dist/src/utils/htmlUtils.js +0 -19
  21. package/dist/src/utils/index.js +0 -24
  22. package/dist/src/utils/mashupDocumentParser.js +0 -188
  23. package/dist/src/utils/pqUtils.js +0 -194
  24. package/dist/src/utils/tableUtils.js +0 -233
  25. package/dist/src/utils/xmlInnerPartsUtils.js +0 -400
  26. package/dist/src/utils/xmlPartsUtils.js +0 -174
  27. package/dist/src/workbookTemplate.js +0 -8
  28. package/dist/tests/arrayUtils.test.js +0 -66
  29. package/dist/tests/documentUtils.test.js +0 -70
  30. package/dist/tests/gridUtils.test.js +0 -214
  31. package/dist/tests/htmlUtils.test.js +0 -111
  32. package/dist/tests/mashupDocumentParser.test.js +0 -113
  33. package/dist/tests/mocks/PqMock.js +0 -7
  34. package/dist/tests/mocks/index.js +0 -24
  35. package/dist/tests/mocks/section1mSimpleQueryMock.js +0 -8
  36. package/dist/tests/mocks/xmlMocks.js +0 -14
  37. package/dist/tests/tableUtils.test.js +0 -70
  38. package/dist/tests/workbookQueryTemplate.test.js +0 -218
  39. package/dist/tests/workbookTableTemplate.test.js +0 -126
  40. package/dist/tests/xmlInnerPartsUtils.test.js +0 -133
package/README.md CHANGED
@@ -374,9 +374,9 @@ Advanced customization options.
374
374
 
375
375
  ```typescript
376
376
  interface FileConfigs {
377
- templateFile?: File; // Custom Excel template
378
- docProps?: DocProps; // Document metadata
379
- hostName?: string; // Creator application name
377
+ templateFile?: File | Buffer; // Custom Excel template
378
+ docProps?: DocProps; // Document metadata
379
+ hostName?: string; // Creator application name
380
380
  TempleteSettings?: TempleteSettings; // Template-specific settings
381
381
  }
382
382
 
package/dist/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  export interface QueryInfo {
2
3
  refreshOnOpen: boolean;
3
4
  queryMashup: string;
@@ -29,7 +30,7 @@ export interface GridConfig {
29
30
  adjustColumnNames?: boolean;
30
31
  }
31
32
  export interface FileConfigs {
32
- templateFile?: File;
33
+ templateFile?: File | Buffer;
33
34
  docProps?: DocProps;
34
35
  hostName?: string;
35
36
  templateSettings?: TemplateSettings;
@@ -1,52 +1,8 @@
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.trueValue = exports.pivotCachesPathPrefix = exports.xmlTextResultType = exports.textResultType = exports.application = exports.uint8ArrayType = exports.blobFileType = 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.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 = 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.tablesFolderPath = "xl/tables/";
15
- exports.pivotCachesPath = "xl/pivotCache/";
16
- exports.section1mPath = "Formulas/Section1.m";
17
- exports.docPropsCoreXmlPath = "docProps/core.xml";
18
- exports.relsXmlPath = "_rels/.rels";
19
- exports.docMetadataXmlPath = "docMetadata";
20
- exports.docPropsRootElement = "cp:coreProperties";
21
- exports.workbookRelsXmlPath = "xl/_rels/workbook.xml.rels";
22
- exports.sharedStringsNotFoundErr = "SharedStrings were not found in template";
23
- exports.connectionsNotFoundErr = "Connections were not found in template";
24
- exports.WorkbookNotFoundERR = "workbook was not found in template";
25
- exports.sheetsNotFoundErr = "Sheets were not found in template";
26
- exports.base64NotFoundErr = "Base64 was not found in template";
27
- exports.emptyQueryMashupErr = "Query mashup is empty";
28
- exports.queryNameNotFoundErr = "Query name was not found";
29
- exports.queryAndPivotTableNotFoundErr = "No such query found in Query Table or Pivot Table found in given template";
30
- exports.queryConnectionNotFoundErr = "No connection found for query";
31
- exports.formulaSectionNotFoundErr = "Formula section wasn't found in template";
32
- exports.templateWithInitialDataErr = "Cannot use a template file with initial data";
33
- exports.queryTableNotFoundErr = "Query table wasn't found in template";
34
- exports.tableNotFoundErr = "Table wasn't found in template";
35
- exports.tableReferenceNotFoundErr = "Reference not found in the table XML.";
36
- exports.invalidValueInColumnErr = "Invalid cell value in column";
37
- exports.headerNotFoundErr = "Invalid JSON file, header is missing";
38
- exports.invalidDataTypeErr = "Invalid JSON file, invalid data type";
39
- exports.QueryNameMaxLengthErr = "Query names are limited to 80 characters";
40
- exports.QueryNameInvalidCharsErr = 'Query names cannot contain periods or quotation marks. (. ")';
41
- exports.EmptyQueryNameErr = "Query name cannot be empty";
42
- exports.stylesNotFoundErr = "Styles were not found in template";
43
- exports.InvalidColumnNameErr = "Invalid column name";
44
- exports.promotedHeadersCannotBeUsedWithoutAdjustingColumnNamesErr = "Headers cannot be promoted without adjusting column names";
45
- exports.unexpectedErr = "Unexpected error";
46
- exports.arrayIsntMxNErr = "Array isn't MxN";
47
- exports.relsNotFoundErr = ".rels were not found in template";
48
- exports.xlRelsNotFoundErr = "workbook.xml.rels were not found xl";
49
- exports.columnIndexOutOfRangeErr = "Column index out of range";
50
6
  exports.blobFileType = "blob";
51
7
  exports.uint8ArrayType = "uint8array";
52
8
  exports.application = "application/xlsx";
@@ -62,6 +18,72 @@ exports.maxQueryLength = 80;
62
18
  exports.trueStr = "true";
63
19
  exports.falseStr = "false";
64
20
  exports.BOM = "\ufeff";
21
+ exports.maxCellCharacters = 32767;
22
+ exports.connectionsXmlPath = "xl/connections.xml";
23
+ exports.sharedStringsXmlPath = "xl/sharedStrings.xml";
24
+ exports.sheetsXmlPath = "xl/worksheets/sheet1.xml";
25
+ exports.tableXmlPath = "xl/tables/table1.xml";
26
+ exports.queryTableXmlPath = "xl/queryTables/queryTable1.xml";
27
+ exports.workbookXmlPath = "xl/workbook.xml";
28
+ exports.queryTablesPath = "xl/queryTables/";
29
+ exports.tablesFolderPath = "xl/tables/";
30
+ exports.pivotCachesPath = "xl/pivotCache/";
31
+ exports.section1mPath = "Formulas/Section1.m";
32
+ exports.docPropsCoreXmlPath = "docProps/core.xml";
33
+ exports.relsXmlPath = "_rels/.rels";
34
+ exports.docMetadataXmlPath = "docMetadata";
35
+ exports.docPropsRootElement = "cp:coreProperties";
36
+ exports.workbookRelsXmlPath = "xl/_rels/workbook.xml.rels";
37
+ exports.labelInfoXmlPath = "docMetadata/LabelInfo.xml";
38
+ exports.docPropsAppXmlPath = "docProps/app.xml";
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
+ };
65
87
  exports.element = {
66
88
  sharedStringTable: "sst",
67
89
  text: "t",
@@ -91,6 +113,9 @@ exports.element = {
91
113
  selection: "selection",
92
114
  kindCell: "c",
93
115
  sheet: "sheet",
116
+ override: "Override",
117
+ relationship: "Relationship",
118
+ relationships: "Relationships",
94
119
  };
95
120
  exports.elementAttributes = {
96
121
  connection: "connection",
@@ -104,7 +129,11 @@ exports.elementAttributes = {
104
129
  name: "name",
105
130
  description: "description",
106
131
  id: "id",
132
+ Id: "Id",
107
133
  relationId: "r:id",
134
+ relationId1: "RId1",
135
+ relationId2: "RId2",
136
+ relationId3: "RId3",
108
137
  type: "Type",
109
138
  value: "Value",
110
139
  relationshipInfo: "RelationshipInfoContainer",
@@ -125,6 +154,9 @@ exports.elementAttributes = {
125
154
  xr3uid: "xr3:uid",
126
155
  space: "xml:space",
127
156
  target: "Target",
157
+ partName: "PartName",
158
+ contentType: "ContentType",
159
+ relationshipIdPrefix: "rId",
128
160
  };
129
161
  exports.dataTypeKind = {
130
162
  string: "str",
@@ -135,7 +167,7 @@ exports.elementAttributesValues = {
135
167
  connectionName: function (queryName) { return "Query - ".concat(queryName); },
136
168
  connectionDescription: function (queryName) { return "Connection to the '".concat(queryName, "' query in the workbook."); },
137
169
  connection: function (queryName) { return "Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=\"".concat(queryName, "\";"); },
138
- connectionCommand: function (queryName) { return "SELECT * FROM [".concat(queryName, "]"); },
170
+ connectionCommand: function (queryName) { return "SELECT * FROM [".concat(queryName.replace(/]/g, ']]'), "]"); },
139
171
  tableResultType: function () { return "sTable"; },
140
172
  };
141
173
  exports.defaults = {
@@ -164,3 +196,18 @@ exports.OFU = {
164
196
  WdOrigin: "wdOrigin",
165
197
  OpenInExcelOririgin: "OpenInExcel",
166
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
@@ -104,7 +104,7 @@ var convertToExcelColumn = function (index) {
104
104
  * @returns Object with numeric row and column.
105
105
  */
106
106
  var GetStartPosition = function (cellRangeRef) {
107
- var match = cellRangeRef.toUpperCase().match(/^([A-Z]+)(\d+):/);
107
+ var match = cellRangeRef.toUpperCase().match(/^([A-Z]+)(\d+)/);
108
108
  if (!match) {
109
109
  return { row: 0, column: 0 };
110
110
  }
@@ -64,15 +64,15 @@ 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) {
@@ -84,7 +84,7 @@ var validateUniqueAndValidDataArray = function (arr) {
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
@@ -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".