@sswroom/sswr 1.6.19 → 1.6.21

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.
@@ -83,122 +83,441 @@ export class XLSXExporter
83
83
  sbContTypes.push("<Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/>");
84
84
  sbContTypes.push("<Default Extension=\"png\" ContentType=\"image/png\"/>");
85
85
  sbContTypes.push("<Default Extension=\"jpeg\" ContentType=\"image/jpeg\"/>");
86
+ sbContTypes.push("<Override PartName=\"/xl/_rels/workbook.xml.rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/>");
87
+
88
+ let row;
86
89
 
90
+ sb = [];
91
+ sb.push("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
92
+ sb.push("<workbook xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\">");
93
+ sb.push("<fileVersion appName=\"AVIRead\"/>");
94
+ sb.push("<workbookPr backupFile=\"false\" showObjects=\"all\" date1904=\"false\"/>");
95
+ sb.push("<workbookProtection/>");
96
+ sb.push("<bookViews>");
97
+ sb.push("<workbookView showHorizontalScroll=\"true\" showVerticalScroll=\"true\" showSheetTabs=\"true\" xWindow=\"0\" yWindow=\"0\" windowWidth=\"16384\" windowHeight=\"8192\" tabRatio=\"500\" firstSheet=\"0\" activeTab=\"0\"/>");
98
+ sb.push("</bookViews>");
99
+ sb.push("<sheets>");
87
100
  i = 0;
88
101
  j = workbook.getCount();
89
102
  while (i < j)
90
103
  {
91
104
  sheet = workbook.getItem(i);
105
+ sb.push("<sheet name=");
106
+ s = sheet.getName();
107
+ s2 = text.toAttrText(s);
108
+ sb.push(s2);
109
+ sb.push(" sheetId=\"");
110
+ sb.push(""+(i + 1));
111
+ sb.push("\" state=\"visible\" r:id=\"rId");
112
+ sb.push(""+(i + 3));
113
+ sb.push("\"/>");
114
+ i++;
115
+ }
116
+ sb.push("</sheets>");
117
+ sb.push("<calcPr iterateCount=\"100\" refMode=\"A1\" iterate=\"false\" iterateDelta=\"0.001\"/>");
118
+ sb.push("</workbook>");
119
+ if (!dirXl)
120
+ {
121
+ zipFile.addDir("xl/", ts, ts, ts, 0);
122
+ dirXl = true;
123
+ }
124
+ zipFile.addFile("xl/workbook.xml", new TextEncoder().encode(sb.join("")), ts, ts, ts, 0);
125
+ sbContTypes.push("<Override PartName=\"/xl/workbook.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml\"/>");
92
126
 
93
- /** @type {{row: number,col: number,cell: spreadsheet.CellData}[]} */
94
- let links = [];
95
- let link;
96
-
97
- sb = [];
98
- sb.push("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
99
- sb.push("<worksheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\">");
100
- sb.push("<sheetPr filterMode=\"false\">");
101
- sb.push("<pageSetUpPr fitToPage=\"false\"/>");
102
- sb.push("</sheetPr>");
103
- sb.push("<dimension ref=\"A1\"/>");
104
- sb.push("<sheetViews>");
105
- sb.push("<sheetView showFormulas=\"false\" showGridLines=\"true\" showRowColHeaders=\"true\" showZeros=\"true\" rightToLeft=\"false\" tabSelected=\"true\" showOutlineSymbols=\"true\" defaultGridColor=\"true\" view=\"normal\" topLeftCell=\"A1\" colorId=\"64\" zoomScale=\"");
106
- sb.push(""+sheet.getZoom());
107
- sb.push("\" zoomScaleNormal=\"");
108
- sb.push(""+sheet.getZoom());
109
- sb.push("\" zoomScalePageLayoutView=\"");
110
- sb.push(""+sheet.getZoom());
111
- sb.push("\" workbookViewId=\"0\">");
112
- sb.push("<selection pane=\"topLeft\" activeCell=\"A1\" activeCellId=\"0\" sqref=\"A1\"/>");
113
- sb.push("</sheetView>");
114
- sb.push("</sheetViews>");
115
- sb.push("<sheetFormatPr defaultColWidth=\"");
116
- sb.push(""+(sheet.getDefColWidthPt() / 5.25));
117
- sb.push("\" defaultRowHeight=\"");
118
- sb.push(""+(sheet.getDefRowHeightPt()));
119
- sb.push("\" zeroHeight=\"false\" outlineLevelRow=\"0\" outlineLevelCol=\"0\"></sheetFormatPr>");
120
- sb.push("<cols>");
127
+ sb = [];
128
+ sb.push("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
129
+ sb.push("<a:theme xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" name=\"Office\">");
130
+ sb.push("<a:themeElements><a:clrScheme name=\"LibreOffice\"><a:dk1><a:srgbClr val=\"000000\"/></a:dk1><a:lt1><a:srgbClr val=\"ffffff\"/></a:lt1><a:dk2><a:srgbClr val=\"000000\"/></a:dk2>");
131
+ sb.push("<a:lt2><a:srgbClr val=\"ffffff\"/></a:lt2><a:accent1><a:srgbClr val=\"18a303\"/></a:accent1><a:accent2><a:srgbClr val=\"0369a3\"/></a:accent2>");
132
+ sb.push("<a:accent3><a:srgbClr val=\"a33e03\"/></a:accent3><a:accent4><a:srgbClr val=\"8e03a3\"/></a:accent4><a:accent5><a:srgbClr val=\"c99c00\"/></a:accent5>");
133
+ sb.push("<a:accent6><a:srgbClr val=\"c9211e\"/></a:accent6><a:hlink><a:srgbClr val=\"0000ee\"/></a:hlink><a:folHlink><a:srgbClr val=\"551a8b\"/></a:folHlink></a:clrScheme>");
134
+ sb.push("<a:fontScheme name=\"Office\"><a:majorFont><a:latin typeface=\"Arial\" pitchFamily=\"0\" charset=\"1\"/><a:ea typeface=\"DejaVu Sans\" pitchFamily=\"0\" charset=\"1\"/>");
135
+ sb.push("<a:cs typeface=\"DejaVu Sans\" pitchFamily=\"0\" charset=\"1\"/></a:majorFont><a:minorFont><a:latin typeface=\"Arial\" pitchFamily=\"0\" charset=\"1\"/><a:ea typeface=\"DejaVu Sans\" pitchFamily=\"0\" charset=\"1\"/>");
136
+ sb.push("<a:cs typeface=\"DejaVu Sans\" pitchFamily=\"0\" charset=\"1\"/></a:minorFont></a:fontScheme><a:fmtScheme><a:fillStyleLst><a:solidFill><a:schemeClr val=\"phClr\"></a:schemeClr></a:solidFill>");
137
+ sb.push("<a:solidFill><a:schemeClr val=\"phClr\"></a:schemeClr></a:solidFill><a:solidFill><a:schemeClr val=\"phClr\"></a:schemeClr></a:solidFill></a:fillStyleLst>");
138
+ sb.push("<a:lnStyleLst><a:ln w=\"6350\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\"><a:prstDash val=\"solid\"/><a:miter/></a:ln><a:ln w=\"6350\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\">");
139
+ sb.push("<a:prstDash val=\"solid\"/><a:miter/></a:ln><a:ln w=\"6350\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\"><a:prstDash val=\"solid\"/><a:miter/></a:ln></a:lnStyleLst>");
140
+ sb.push("<a:effectStyleLst><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst/></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst>");
141
+ sb.push("<a:solidFill><a:schemeClr val=\"phClr\"></a:schemeClr></a:solidFill><a:solidFill><a:schemeClr val=\"phClr\"></a:schemeClr></a:solidFill><a:solidFill><a:schemeClr val=\"phClr\"></a:schemeClr></a:solidFill></a:bgFillStyleLst></a:fmtScheme></a:themeElements></a:theme>");
142
+ zipFile.addDir("xl/theme/", ts, ts, ts, 0);
143
+ zipFile.addFile("xl/theme/theme1.xml", new TextEncoder().encode(sb.join("")), ts, ts, ts, 0);
144
+ sbContTypes.push("<Override PartName=\"/xl/theme/theme1.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.theme+xml\"/>");
145
+
146
+ sb = [];
147
+ sb.push("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
148
+ sb.push("<styleSheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">");
149
+ {
150
+ /** @type {{ [x: string]: number; }} */
151
+ let numFmtMap = {};
152
+ /** @type {string[]} */
153
+ let numFmts = [];
154
+ let borders = [];
155
+ let borderNone = new spreadsheet.BorderStyle(0, spreadsheet.BorderType.None);
156
+ let border = {left: borderNone, top: borderNone, right: borderNone, bottom: borderNone};
157
+ borders.push(border);
121
158
 
122
- let lastColWidth = -1;
123
- let lastColIndex = -1;
159
+ s = "General";
160
+ numFmtMap[s] = numFmts.length;;
161
+ numFmts.push(s);
124
162
 
125
- k = 0;
126
- l = sheet.getColWidthCount();
127
- while (k < l)
163
+ i = 0;
164
+ j = workbook.getStyleCount();
165
+ while (i < j)
128
166
  {
129
- if (sheet.getColWidthPt(k) != lastColWidth)
167
+ let style = workbook.getStyle(i);
168
+ if (style == null)
169
+ throw new Error("Style is null");
170
+ if ((s = style.getDataFormat()) == null)
130
171
  {
131
- if (lastColIndex != -1)
172
+ s = "General";
173
+ }
174
+ if (numFmtMap[s] === undefined)
175
+ {
176
+ numFmtMap[s] = numFmts.length;
177
+ numFmts.push(s);
178
+ }
179
+ let borderFound = false;
180
+ k = borders.length;
181
+ while (k-- > 0)
182
+ {
183
+ border = borders[k];
184
+ if (border.left.equals(style.getBorderLeft()) &&
185
+ border.top.equals(style.getBorderTop()) &&
186
+ border.right.equals(style.getBorderRight()) &&
187
+ border.bottom.equals(style.getBorderBottom()))
132
188
  {
133
- sb.push("<col min=\"");
134
- sb.push(""+(lastColIndex + 10));
135
- sb.push("\" max=\"");
136
- sb.push(""+k);
137
- sb.push("\" width=\"");
138
- if (lastColWidth >= 0)
139
- {
140
- sb.push(""+(lastColWidth / 5.25));
141
- sb.push("\" customWidth=\"1\"");
142
- }
143
- else
144
- {
145
- sb.push(""+(sheet.getDefColWidthPt() / 5.25));
146
- sb.push("\" customWidth=\"false\"");
147
- }
148
- sb.push("/>");
189
+ borderFound = true;
190
+ break;
149
191
  }
150
- lastColWidth = sheet.getColWidthPt(k);
151
- lastColIndex = k;
152
192
  }
153
- k++;
154
- }
155
- if (lastColWidth >= 0)
156
- {
157
- sb.push("<col min=\"");
158
- sb.push(""+(lastColIndex + 1));
159
- sb.push("\" max=\"");
160
- sb.push(""+l);
161
- sb.push("\" width=\"");
162
- if (lastColWidth >= 0)
193
+ if (!borderFound)
163
194
  {
164
- sb.push(""+(lastColWidth / 5.25));
165
- sb.push("\" customWidth=\"1\"");
195
+ border = {left: style.getBorderLeft(), top: style.getBorderTop(), right: style.getBorderRight(), bottom: style.getBorderBottom()};
196
+ borders.push(border);
166
197
  }
167
- else
198
+ i++;
199
+ }
200
+ if (numFmts.length > 0)
201
+ {
202
+ sb.push("<numFmts count=\"");
203
+ sb.push(""+numFmts.length);
204
+ sb.push("\">");
205
+ i = 0;
206
+ k = numFmts.length;
207
+ while (i < k)
168
208
  {
169
- sb.push(""+(sheet.getDefColWidthPt() / 5.25));
170
- sb.push("\" customWidth=\"false\"");
209
+ sb.push("<numFmt numFmtId=\"");
210
+ sb.push(""+(i + 164));
211
+ sb.push("\" formatCode=");
212
+ s = text.toAttrText(XLSXExporter.toFormatCode(numFmts[i]));
213
+ sb.push(s);
214
+ sb.push("/>");
215
+ i++;
171
216
  }
172
- sb.push("/>");
217
+ sb.push("</numFmts>");
173
218
  }
174
- if (l < sheet.getMaxCol())
219
+ if (workbook.getFontCount() > 0)
175
220
  {
176
- sb.push("<col min=\"");
177
- sb.push(""+(l + 1));
178
- sb.push("\" max=\"");
179
- sb.push(""+(sheet.getMaxCol()));
180
- sb.push("\" width=\"");
181
- sb.push(""+(sheet.getDefColWidthPt() / 5.25));
182
- sb.push("\" customWidth=\"false\" collapsed=\"false\" hidden=\"false\" outlineLevel=\"0\" style=\"0\"/>");
221
+ sb.push("<fonts count=\"");
222
+ sb.push(""+workbook.getFontCount());
223
+ sb.push("\">");
224
+ i = 0;
225
+ k = workbook.getFontCount();
226
+ while (i < k)
227
+ {
228
+ let font = workbook.getFontNoCheck(i);
229
+ sb.push("<font>");
230
+ if (font.getSize() != 0)
231
+ {
232
+ sb.push("<sz val=\"");
233
+ sb.push(""+font.getSize());
234
+ sb.push("\"/>");
235
+ }
236
+ if ((s = font.getName()) != null)
237
+ {
238
+ sb.push("<name val=");
239
+ s = text.toAttrText(s);
240
+ sb.push(s);
241
+ sb.push("/>");
242
+ }
243
+ switch (font.getFamily())
244
+ {
245
+ case spreadsheet.FontFamily.NA:
246
+ sb.push("<family val=\"0\"/>");
247
+ break;
248
+ case spreadsheet.FontFamily.Roman:
249
+ sb.push("<family val=\"1\"/>");
250
+ break;
251
+ case spreadsheet.FontFamily.Swiss:
252
+ sb.push("<family val=\"2\"/>");
253
+ break;
254
+ case spreadsheet.FontFamily.Modern:
255
+ sb.push("<family val=\"3\"/>");
256
+ break;
257
+ case spreadsheet.FontFamily.Script:
258
+ sb.push("<family val=\"4\"/>");
259
+ break;
260
+ case spreadsheet.FontFamily.Decorative:
261
+ sb.push("<family val=\"5\"/>");
262
+ break;
263
+ }
264
+ sb.push("</font>");
265
+ i++;
266
+ }
267
+ sb.push("</fonts>");
183
268
  }
184
269
 
185
- sb.push("</cols>");
186
-
187
- /** @type {math.RectArea[]} */
188
- let mergeList = [];
189
- k = 0;
190
- l = sheet.getCount();
191
- if (l > 0)
270
+ sb.push("<fills count=\"2\">");
271
+ sb.push("<fill>");
272
+ sb.push("<patternFill patternType=\"none\"/>");
273
+ sb.push("</fill>");
274
+ sb.push("<fill>");
275
+ sb.push("<patternFill patternType=\"gray125\"/>");
276
+ sb.push("</fill>");
277
+ sb.push("</fills>");
278
+
279
+ i = 0;
280
+ k = borders.length;
281
+ sb.push("<borders count=\"");
282
+ sb.push(""+k);
283
+ sb.push("\">");
284
+ while (i < k)
192
285
  {
193
- sb.push("<sheetData>");
194
- while (k < l)
195
- {
196
- let row;
197
- if ((row = sheet.getItem(k)) != null)
198
- {
199
- sb.push("<row r=\"");
200
- sb.push(""+(k + 1));
201
- sb.push("\" customFormat=\"false\" ht=\"12.8\" hidden=\"false\" customHeight=\"false\" outlineLevel=\"0\" collapsed=\"false\">");
286
+ border = borders[i];
287
+ sb.push("<border diagonalUp=\"false\" diagonalDown=\"false\">");
288
+ XLSXExporter.appendBorder(sb, border.left, "left");
289
+ XLSXExporter.appendBorder(sb, border.right, "right");
290
+ XLSXExporter.appendBorder(sb, border.top, "top");
291
+ XLSXExporter.appendBorder(sb, border.bottom, "bottom");
292
+ sb.push("<diagonal/>");
293
+ sb.push("</border>");
294
+ i++;
295
+ }
296
+ sb.push("</borders>");
297
+
298
+ sb.push("<cellStyleXfs count=\"20\">");
299
+ sb.push("<xf numFmtId=\"164\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"true\" applyAlignment=\"true\" applyProtection=\"true\">");
300
+ sb.push("<alignment horizontal=\"general\" vertical=\"bottom\" textRotation=\"0\" wrapText=\"false\" indent=\"0\" shrinkToFit=\"false\"/>");
301
+ sb.push("<protection locked=\"true\" hidden=\"false\"/>");
302
+ sb.push("</xf>");
303
+ sb.push("<xf numFmtId=\"1\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
304
+ sb.push("</xf>");
305
+ sb.push("<xf numFmtId=\"1\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
306
+ sb.push("</xf>");
307
+ sb.push("<xf numFmtId=\"2\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
308
+ sb.push("</xf>");
309
+ sb.push("<xf numFmtId=\"2\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
310
+ sb.push("</xf>");
311
+ sb.push("<xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
312
+ sb.push("</xf>");
313
+ sb.push("<xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
314
+ sb.push("</xf>");
315
+ sb.push("<xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
316
+ sb.push("</xf>");
317
+ sb.push("<xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
318
+ sb.push("</xf>");
319
+ sb.push("<xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
320
+ sb.push("</xf>");
321
+ sb.push("<xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
322
+ sb.push("</xf>");
323
+ sb.push("<xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
324
+ sb.push("</xf>");
325
+ sb.push("<xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
326
+ sb.push("</xf>");
327
+ sb.push("<xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
328
+ sb.push("</xf>");
329
+ sb.push("<xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
330
+ sb.push("</xf>");
331
+ sb.push("<xf numFmtId=\"43\" fontId=\"1\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
332
+ sb.push("</xf>");
333
+ sb.push("<xf numFmtId=\"41\" fontId=\"1\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
334
+ sb.push("</xf>");
335
+ sb.push("<xf numFmtId=\"44\" fontId=\"1\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
336
+ sb.push("</xf>");
337
+ sb.push("<xf numFmtId=\"42\" fontId=\"1\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
338
+ sb.push("</xf>");
339
+ sb.push("<xf numFmtId=\"9\" fontId=\"1\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
340
+ sb.push("</xf>");
341
+ sb.push("</cellStyleXfs>");
342
+
343
+ if (workbook.getStyleCount() > 0)
344
+ {
345
+ sb.push("<cellXfs count=\"");
346
+ sb.push(""+workbook.getStyleCount());
347
+ sb.push("\">");
348
+ i = 0;
349
+ k = workbook.getStyleCount();
350
+ while (i < k)
351
+ {
352
+ let style;
353
+ if ((style = workbook.getStyle(i)) != null)
354
+ {
355
+ XLSXExporter.appendXF(sb, style, borders, workbook, numFmtMap);
356
+ }
357
+ i++;
358
+ }
359
+ sb.push("</cellXfs>");
360
+ }
361
+
362
+ sb.push("<cellStyles count=\"6\">");
363
+ sb.push("<cellStyle name=\"Normal\" xfId=\"0\" builtinId=\"0\"/>");
364
+ sb.push("<cellStyle name=\"Comma\" xfId=\"15\" builtinId=\"3\"/>");
365
+ sb.push("<cellStyle name=\"Comma [0]\" xfId=\"16\" builtinId=\"6\"/>");
366
+ sb.push("<cellStyle name=\"Currency\" xfId=\"17\" builtinId=\"4\"/>");
367
+ sb.push("<cellStyle name=\"Currency [0]\" xfId=\"18\" builtinId=\"7\"/>");
368
+ sb.push("<cellStyle name=\"Percent\" xfId=\"19\" builtinId=\"5\"/>");
369
+ sb.push("</cellStyles>");
370
+ }
371
+ sb.push("</styleSheet>");
372
+ zipFile.addFile("xl/styles.xml", new TextEncoder().encode(sb.join("")), ts, ts, ts, 0);
373
+ sbContTypes.push("<Override PartName=\"/xl/styles.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml\"/>");
374
+
375
+ i = 0;
376
+ j = workbook.getCount();
377
+ while (i < j)
378
+ {
379
+ sheet = workbook.getItem(i);
380
+ let maxRow = sheet.getCount();
381
+ let maxCol = 1;
382
+ k = 0;
383
+ while (k < maxRow)
384
+ {
385
+ if ((row = sheet.getItem(k)) != null && row.cells.length > maxCol)
386
+ {
387
+ maxCol = row.cells.length;
388
+ }
389
+ k++;
390
+ }
391
+ /** @type {{row: number,col: number,cell: spreadsheet.CellData}[]} */
392
+ let links = [];
393
+ let link;
394
+
395
+ sb = [];
396
+ sb.push("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
397
+ sb.push("<worksheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:xdr=\"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing\" xmlns:x14=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main\" xmlns:xr2=\"http://schemas.microsoft.com/office/spreadsheetml/2015/revision2\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\">");
398
+ sb.push("<sheetPr filterMode=\"false\">");
399
+ sb.push("<pageSetUpPr fitToPage=\"false\"/>");
400
+ sb.push("</sheetPr>");
401
+ sb.push("<dimension ref=\"A1");
402
+ if (maxRow > 1 || maxCol > 1)
403
+ {
404
+ sb.push(':'+spreadsheet.XLSUtil.getCellID(maxCol - 1, maxRow - 1));
405
+ }
406
+ sb.push("\"/>");
407
+ sb.push("<sheetViews>");
408
+ sb.push("<sheetView showFormulas=\"false\" showGridLines=\"true\" showRowColHeaders=\"true\" showZeros=\"true\" rightToLeft=\"false\" tabSelected=\"true\" showOutlineSymbols=\"true\" defaultGridColor=\"true\" view=\"normal\" topLeftCell=\"A1\" colorId=\"64\" zoomScale=\"");
409
+ sb.push(""+sheet.getZoom());
410
+ sb.push("\" zoomScaleNormal=\"");
411
+ sb.push(""+sheet.getZoom());
412
+ sb.push("\" zoomScalePageLayoutView=\"");
413
+ sb.push(""+sheet.getZoom());
414
+ sb.push("\" workbookViewId=\"0\">");
415
+ sb.push("<selection pane=\"topLeft\" activeCell=\"A1\" activeCellId=\"0\" sqref=\"A1\"/>");
416
+ sb.push("</sheetView>");
417
+ sb.push("</sheetViews>");
418
+ sb.push("<sheetFormatPr defaultColWidth=\"");
419
+ sb.push(""+(sheet.getDefColWidthPt() / 5.25));
420
+ sb.push("\" defaultRowHeight=\"");
421
+ sb.push(""+(sheet.getDefRowHeightPt()));
422
+ sb.push("\" zeroHeight=\"false\" outlineLevelRow=\"0\" outlineLevelCol=\"0\"></sheetFormatPr>");
423
+ let found = false;
424
+
425
+ let lastColWidth = -1;
426
+ let lastColIndex = -1;
427
+
428
+ k = 0;
429
+ l = sheet.getColWidthCount();
430
+ while (k < l)
431
+ {
432
+ if (sheet.getColWidthPt(k) != lastColWidth)
433
+ {
434
+ if (lastColIndex != -1)
435
+ {
436
+ if (!found)
437
+ {
438
+ found = true;
439
+ sb.push("<cols>");
440
+ }
441
+ sb.push("<col min=\"");
442
+ sb.push(""+(lastColIndex + 10));
443
+ sb.push("\" max=\"");
444
+ sb.push(""+k);
445
+ sb.push("\" width=\"");
446
+ if (lastColWidth >= 0)
447
+ {
448
+ sb.push(""+(lastColWidth / 5.25));
449
+ sb.push("\" customWidth=\"1\"");
450
+ }
451
+ else
452
+ {
453
+ sb.push(""+(sheet.getDefColWidthPt() / 5.25));
454
+ sb.push("\" customWidth=\"false\"");
455
+ }
456
+ sb.push("/>");
457
+ }
458
+ lastColWidth = sheet.getColWidthPt(k);
459
+ lastColIndex = k;
460
+ }
461
+ k++;
462
+ }
463
+ if (lastColWidth >= 0)
464
+ {
465
+ if (!found)
466
+ {
467
+ found = true;
468
+ sb.push("<cols>");
469
+ }
470
+ sb.push("<col min=\"");
471
+ sb.push(""+(lastColIndex + 1));
472
+ sb.push("\" max=\"");
473
+ sb.push(""+l);
474
+ sb.push("\" width=\"");
475
+ if (lastColWidth >= 0)
476
+ {
477
+ sb.push(""+(lastColWidth / 5.25));
478
+ sb.push("\" customWidth=\"1\"");
479
+ }
480
+ else
481
+ {
482
+ sb.push(""+(sheet.getDefColWidthPt() / 5.25));
483
+ sb.push("\" customWidth=\"false\"");
484
+ }
485
+ sb.push("/>");
486
+ }
487
+ if (l < sheet.getMaxCol())
488
+ {
489
+ if (!found)
490
+ {
491
+ found = true;
492
+ sb.push("<cols>");
493
+ }
494
+ sb.push("<col min=\"");
495
+ sb.push(""+(l + 1));
496
+ sb.push("\" max=\"");
497
+ sb.push(""+(sheet.getMaxCol()));
498
+ sb.push("\" width=\"");
499
+ sb.push(""+(sheet.getDefColWidthPt() / 5.25));
500
+ sb.push("\" customWidth=\"false\" collapsed=\"false\" hidden=\"false\" outlineLevel=\"0\" style=\"0\"/>");
501
+ }
502
+ if (found)
503
+ {
504
+ sb.push("</cols>");
505
+ }
506
+
507
+ /** @type {math.RectArea[]} */
508
+ let mergeList = [];
509
+ k = 0;
510
+ l = sheet.getCount();
511
+ if (l > 0)
512
+ {
513
+ sb.push("<sheetData>");
514
+ while (k < l)
515
+ {
516
+ if ((row = sheet.getItem(k)) != null)
517
+ {
518
+ sb.push("<row r=\"");
519
+ sb.push(""+(k + 1));
520
+ sb.push("\" customFormat=\"false\" ht=\"12.8\" hidden=\"false\" customHeight=\"false\" outlineLevel=\"0\" collapsed=\"false\">");
202
521
 
203
522
  m = 0;
204
523
  n = row.cells.length;
@@ -432,7 +751,7 @@ export class XLSXExporter
432
751
  let chart;
433
752
  let drawing = sheet.getDrawingNoCheck(k);
434
753
  sb = [];
435
- sb.push("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
754
+ sb.push("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
436
755
  sb.push("<xdr:wsDr xmlns:xdr=\"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\">");
437
756
  switch (drawing.anchorType)
438
757
  {
@@ -555,437 +874,156 @@ export class XLSXExporter
555
874
  sb.push("</xdr:wsDr>");
556
875
  drawingCnt++;
557
876
  if (!dirXlDraw)
558
- {
559
- dirXlDraw = true;
560
- zipFile.addDir("xl/drawings/", ts, ts, ts, 0);
561
- }
562
- s = "xl/drawings/drawing" + drawingCnt +".xml";
563
- zipFile.addFile(s, new TextEncoder().encode(sb.join("")), ts, ts, ts, 0);
564
- sbContTypes.push("<Override PartName=\"/");
565
- sbContTypes.push(s);
566
- sbContTypes.push("\" ContentType=\"application/vnd.openxmlformats-officedocument.drawing+xml\"/>");
567
-
568
- if ((chart = drawing.chart) != null)
569
- {
570
- sb = [];
571
- sb.push("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>");
572
- sb.push("<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">");
573
- sb.push("<Relationship Id=\"rId1\" Target=\"../charts/chart");
574
- sb.push(""+(chartCnt + 1));
575
- sb.push(".xml\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart\"/>");
576
- sb.push("</Relationships>");
577
-
578
- if (!dirXlDrawRel)
579
- {
580
- dirXlDrawRel = true;
581
- zipFile.addDir("xl/drawings/_rels/", ts, ts, ts, 0);
582
- }
583
- s = "xl/drawings/_rels/drawing"+ drawingCnt+".xml.rels";
584
- zipFile.addFile(s, new TextEncoder().encode(sb.join("")), ts, ts, ts, 0);
585
- sbContTypes.push("<Override PartName=\"/");
586
- sbContTypes.push(s);
587
- sbContTypes.push("\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/>");
588
-
589
- chartCnt++;
590
- sb = [];
591
- sb.push("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
592
- sb.push("<c:chartSpace xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">");
593
- sb.push("<c:chart>");
594
- if ((s = chart.getTitleText()) != null)
595
- {
596
- XLSXExporter.appendTitle(sb, s);
597
- }
598
- sb.push("<c:plotArea>");
599
- sb.push("<c:layout/>");
600
- if (chart.getChartType() != spreadsheet.ChartType.Unknown)
601
- {
602
- let nnaxis;
603
- switch (chart.getChartType())
604
- {
605
- case spreadsheet.ChartType.LineChart:
606
- sb.push("<c:lineChart>");
607
- break;
608
- case spreadsheet.ChartType.Unknown:
609
- break;
610
- }
611
- m = 0;
612
- n = chart.getSeriesCount();
613
- while (m < n)
614
- {
615
- XLSXExporter.appendSeries(sb, chart.getSeriesNoCheck(m), m);
616
- m++;
617
- }
618
- if ((nnaxis = chart.getCategoryAxis()) != null)
619
- {
620
- sb.push("<c:axId val=\"");
621
- sb.push(""+chart.getAxisIndex(nnaxis));
622
- sb.push("\"/>");
623
- }
624
- if ((nnaxis = chart.getValueAxis()) != null)
625
- {
626
- sb.push("<c:axId val=\"");
627
- sb.push(""+ chart.getAxisIndex(nnaxis));
628
- sb.push("\"/>");
629
- }
630
- switch (chart.getChartType())
631
- {
632
- case spreadsheet.ChartType.LineChart:
633
- sb.push("</c:lineChart>");
634
- break;
635
- case spreadsheet.ChartType.Unknown:
636
- break;
637
- }
638
- }
639
- m = 0;
640
- n = chart.getAxisCount();
641
- while (m < n)
642
- {
643
- XLSXExporter.appendAxis(sb, chart.getAxis(m), m);
644
- m++;
645
- }
646
- XLSXExporter.appendShapeProp(sb, chart.getShapeProp());
647
- sb.push("</c:plotArea>");
648
- if (chart.hasLegend())
649
- {
650
- sb.push("<c:legend>");
651
- sb.push("<c:legendPos val=\"");
652
- switch (chart.getLegendPos())
653
- {
654
- case spreadsheet.LegendPos.Bottom:
655
- sb.push("b");
656
- break;
657
- }
658
- sb.push("\"/>");
659
- sb.push("<c:overlay val=\"");
660
- if (chart.isLegendOverlay())
661
- {
662
- sb.push("true");
663
- }
664
- else
665
- {
666
- sb.push("false");
667
- }
668
- sb.push("\"/>");
669
- sb.push("</c:legend>");
670
- }
671
- sb.push("<c:plotVisOnly val=\"true\"/>");
672
- switch (chart.getDisplayBlankAs())
673
- {
674
- case spreadsheet.BlankAs.Default:
675
- break;
676
- case spreadsheet.BlankAs.Gap:
677
- sb.push("<c:dispBlanksAs val=\"gap\"/>");
678
- break;
679
- case spreadsheet.BlankAs.Zero:
680
- sb.push("<c:dispBlanksAs val=\"zero\"/>");
681
- break;
682
- }
683
- sb.push("</c:chart>");
684
- //////////////////////////////////////
685
- sb.push("</c:chartSpace>");
686
-
687
- if (!dirXlChart)
688
- {
689
- dirXlChart = true;
690
- zipFile.addDir("xl/charts/", ts, ts, ts, 0);
691
- }
692
- s = "xl/charts/chart" + chartCnt + ".xml";
693
- zipFile.addFile(s, new TextEncoder().encode(sb.join("")), ts, ts, ts, 0);
694
- sbContTypes.push("<Override PartName=\"/");
695
- sbContTypes.push(s);
696
- sbContTypes.push("\" ContentType=\"application/vnd.openxmlformats-officedocument.drawingml.chart+xml\"/>");
697
- }
698
- k++;
699
- }
700
- }
701
- i++;
702
- }
703
-
704
- sb = [];
705
- sb.push("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
706
- sb.push("<workbook xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\">");
707
- sb.push("<fileVersion appName=\"AVIRead\"/>");
708
- sb.push("<workbookPr backupFile=\"false\" showObjects=\"all\" date1904=\"false\"/>");
709
- sb.push("<workbookProtection/>");
710
- sb.push("<bookViews>");
711
- sb.push("<workbookView showHorizontalScroll=\"true\" showVerticalScroll=\"true\" showSheetTabs=\"true\" xWindow=\"0\" yWindow=\"0\" windowWidth=\"16384\" windowHeight=\"8192\" tabRatio=\"500\" firstSheet=\"0\" activeTab=\"0\"/>");
712
- sb.push("</bookViews>");
713
- sb.push("<sheets>");
714
- i = 0;
715
- j = workbook.getCount();
716
- while (i < j)
717
- {
718
- sheet = workbook.getItem(i);
719
- sb.push("<sheet name=");
720
- s = sheet.getName();
721
- s2 = text.toAttrText(s);
722
- sb.push(s2);
723
- sb.push(" sheetId=\"");
724
- sb.push(""+(i + 1));
725
- sb.push("\" state=\"visible\" r:id=\"rId");
726
- sb.push(""+(i + 2));
727
- sb.push("\"/>");
728
- i++;
729
- }
730
- sb.push("</sheets>");
731
- sb.push("<calcPr iterateCount=\"100\" refMode=\"A1\" iterate=\"false\" iterateDelta=\"0.001\"/>");
732
- sb.push("</workbook>");
733
- if (!dirXl)
734
- {
735
- zipFile.addDir("xl/", ts, ts, ts, 0);
736
- dirXl = true;
737
- }
738
- zipFile.addFile("xl/workbook.xml", new TextEncoder().encode(sb.join("")), ts, ts, ts, 0);
739
- sbContTypes.push("<Override PartName=\"/xl/workbook.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml\"/>");
740
-
741
- sb = [];
742
- sb.push("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
743
- sb.push("<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">");
744
- sb.push("<Relationship Id=\"rId1\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument\" Target=\"xl/workbook.xml\"/>");
745
- sb.push("<Relationship Id=\"rId2\" Type=\"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties\" Target=\"docProps/core.xml\"/>");
746
- sb.push("<Relationship Id=\"rId3\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties\" Target=\"docProps/app.xml\"/>");
747
- sb.push("\n</Relationships>");
748
- if (!dirRel)
749
- {
750
- zipFile.addDir("_rels/", ts, ts, ts, 0);
751
- dirRel = true;
752
- }
753
- zipFile.addFile("_rels/.rels", new TextEncoder().encode(sb.join("")), ts, ts, ts, 0);
754
- sbContTypes.push("<Override PartName=\"/_rels/.rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/>");
755
-
756
- sb = [];
757
- sb.push("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n");
758
- sb.push("<styleSheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">");
759
- {
760
- /** @type {{ [x: string]: number; }} */
761
- let numFmtMap = {};
762
- /** @type {string[]} */
763
- let numFmts = [];
764
- let borders = [];
765
- let borderNone = new spreadsheet.BorderStyle(0, spreadsheet.BorderType.None);
766
- let border = {left: borderNone, top: borderNone, right: borderNone, bottom: borderNone};
767
- borders.push(border);
768
-
769
- s = "general";
770
- numFmtMap[s] = numFmts.length;;
771
- numFmts.push(s);
772
-
773
- i = 0;
774
- j = workbook.getStyleCount();
775
- while (i < j)
776
- {
777
- let style = workbook.getStyle(i);
778
- if (style == null)
779
- throw new Error("Style is null");
780
- if ((s = style.getDataFormat()) == null)
781
- {
782
- s = "general";
783
- }
784
- if (numFmtMap[s] === undefined)
785
- {
786
- numFmtMap[s] = numFmts.length;
787
- numFmts.push(s);
788
- }
789
- let borderFound = false;
790
- k = borders.length;
791
- while (k-- > 0)
792
- {
793
- border = borders[k];
794
- if (border.left.equals(style.getBorderLeft()) &&
795
- border.top.equals(style.getBorderTop()) &&
796
- border.right.equals(style.getBorderRight()) &&
797
- border.bottom.equals(style.getBorderBottom()))
798
- {
799
- borderFound = true;
800
- break;
801
- }
802
- }
803
- if (!borderFound)
804
- {
805
- border = {left: style.getBorderLeft(), top: style.getBorderTop(), right: style.getBorderRight(), bottom: style.getBorderBottom()};
806
- borders.push(border);
807
- }
808
- i++;
809
- }
810
- if (numFmts.length > 0)
811
- {
812
- sb.push("<numFmts count=\"");
813
- sb.push(""+numFmts.length);
814
- sb.push("\">");
815
- i = 0;
816
- k = numFmts.length;
817
- while (i < k)
818
- {
819
- sb.push("<numFmt numFmtId=\"");
820
- sb.push(""+(i + 164));
821
- sb.push("\" formatCode=");
822
- s = text.toAttrText(XLSXExporter.toFormatCode(numFmts[i]));
823
- sb.push(s);
824
- sb.push("/>");
825
- i++;
826
- }
827
- sb.push("</numFmts>");
828
- }
829
- if (workbook.getFontCount() > 0)
830
- {
831
- sb.push("<fonts count=\"");
832
- sb.push(""+workbook.getFontCount());
833
- sb.push("\">");
834
- i = 0;
835
- k = workbook.getFontCount();
836
- while (i < k)
837
- {
838
- let font = workbook.getFontNoCheck(i);
839
- sb.push("<font>");
840
- if (font.getSize() != 0)
841
- {
842
- sb.push("<sz val=\"");
843
- sb.push(""+font.getSize());
844
- sb.push("\"/>");
845
- }
846
- if ((s = font.getName()) != null)
847
- {
848
- sb.push("<name val=");
849
- s = text.toAttrText(s);
850
- sb.push(s);
851
- sb.push("/>");
852
- }
853
- switch (font.getFamily())
854
- {
855
- case spreadsheet.FontFamily.NA:
856
- sb.push("<family val=\"0\"/>");
857
- break;
858
- case spreadsheet.FontFamily.Roman:
859
- sb.push("<family val=\"1\"/>");
860
- break;
861
- case spreadsheet.FontFamily.Swiss:
862
- sb.push("<family val=\"2\"/>");
863
- break;
864
- case spreadsheet.FontFamily.Modern:
865
- sb.push("<family val=\"3\"/>");
866
- break;
867
- case spreadsheet.FontFamily.Script:
868
- sb.push("<family val=\"4\"/>");
869
- break;
870
- case spreadsheet.FontFamily.Decorative:
871
- sb.push("<family val=\"5\"/>");
872
- break;
873
- }
874
- sb.push("</font>");
875
- i++;
876
- }
877
- sb.push("</fonts>");
878
- }
877
+ {
878
+ dirXlDraw = true;
879
+ zipFile.addDir("xl/drawings/", ts, ts, ts, 0);
880
+ }
881
+ s = "xl/drawings/drawing" + drawingCnt +".xml";
882
+ zipFile.addFile(s, new TextEncoder().encode(sb.join("")), ts, ts, ts, 0);
883
+ sbContTypes.push("<Override PartName=\"/");
884
+ sbContTypes.push(s);
885
+ sbContTypes.push("\" ContentType=\"application/vnd.openxmlformats-officedocument.drawing+xml\"/>");
879
886
 
880
- sb.push("<fills count=\"2\">");
881
- sb.push("<fill>");
882
- sb.push("<patternFill patternType=\"none\"/>");
883
- sb.push("</fill>");
884
- sb.push("<fill>");
885
- sb.push("<patternFill patternType=\"gray125\"/>");
886
- sb.push("</fill>");
887
- sb.push("</fills>");
887
+ if ((chart = drawing.chart) != null)
888
+ {
889
+ sb = [];
890
+ sb.push("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>");
891
+ sb.push("<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">");
892
+ sb.push("<Relationship Id=\"rId1\" Target=\"../charts/chart");
893
+ sb.push(""+(chartCnt + 1));
894
+ sb.push(".xml\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart\"/>");
895
+ sb.push("</Relationships>");
888
896
 
889
- i = 0;
890
- k = borders.length;
891
- sb.push("<borders count=\"");
892
- sb.push(""+k);
893
- sb.push("\">");
894
- while (i < k)
895
- {
896
- border = borders[i];
897
- sb.push("<border diagonalUp=\"false\" diagonalDown=\"false\">");
898
- XLSXExporter.appendBorder(sb, border.left, "left");
899
- XLSXExporter.appendBorder(sb, border.right, "right");
900
- XLSXExporter.appendBorder(sb, border.top, "top");
901
- XLSXExporter.appendBorder(sb, border.bottom, "bottom");
902
- sb.push("<diagonal/>");
903
- sb.push("</border>");
904
- i++;
905
- }
906
- sb.push("</borders>");
897
+ if (!dirXlDrawRel)
898
+ {
899
+ dirXlDrawRel = true;
900
+ zipFile.addDir("xl/drawings/_rels/", ts, ts, ts, 0);
901
+ }
902
+ s = "xl/drawings/_rels/drawing"+ drawingCnt+".xml.rels";
903
+ zipFile.addFile(s, new TextEncoder().encode(sb.join("")), ts, ts, ts, 0);
904
+ sbContTypes.push("<Override PartName=\"/");
905
+ sbContTypes.push(s);
906
+ sbContTypes.push("\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/>");
907
907
 
908
- sb.push("<cellStyleXfs count=\"20\">");
909
- sb.push("<xf numFmtId=\"164\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"true\" applyAlignment=\"true\" applyProtection=\"true\">");
910
- sb.push("<alignment horizontal=\"general\" vertical=\"bottom\" textRotation=\"0\" wrapText=\"false\" indent=\"0\" shrinkToFit=\"false\"/>");
911
- sb.push("<protection locked=\"true\" hidden=\"false\"/>");
912
- sb.push("</xf>");
913
- sb.push("<xf numFmtId=\"1\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
914
- sb.push("</xf>");
915
- sb.push("<xf numFmtId=\"1\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
916
- sb.push("</xf>");
917
- sb.push("<xf numFmtId=\"2\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
918
- sb.push("</xf>");
919
- sb.push("<xf numFmtId=\"2\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
920
- sb.push("</xf>");
921
- sb.push("<xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
922
- sb.push("</xf>");
923
- sb.push("<xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
924
- sb.push("</xf>");
925
- sb.push("<xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
926
- sb.push("</xf>");
927
- sb.push("<xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
928
- sb.push("</xf>");
929
- sb.push("<xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
930
- sb.push("</xf>");
931
- sb.push("<xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
932
- sb.push("</xf>");
933
- sb.push("<xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
934
- sb.push("</xf>");
935
- sb.push("<xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
936
- sb.push("</xf>");
937
- sb.push("<xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
938
- sb.push("</xf>");
939
- sb.push("<xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
940
- sb.push("</xf>");
941
- sb.push("<xf numFmtId=\"43\" fontId=\"1\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
942
- sb.push("</xf>");
943
- sb.push("<xf numFmtId=\"41\" fontId=\"1\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
944
- sb.push("</xf>");
945
- sb.push("<xf numFmtId=\"44\" fontId=\"1\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
946
- sb.push("</xf>");
947
- sb.push("<xf numFmtId=\"42\" fontId=\"1\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
948
- sb.push("</xf>");
949
- sb.push("<xf numFmtId=\"9\" fontId=\"1\" fillId=\"0\" borderId=\"0\" applyFont=\"true\" applyBorder=\"false\" applyAlignment=\"false\" applyProtection=\"false\">");
950
- sb.push("</xf>");
951
- sb.push("</cellStyleXfs>");
908
+ chartCnt++;
909
+ sb = [];
910
+ sb.push("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
911
+ sb.push("<c:chartSpace xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">");
912
+ sb.push("<c:chart>");
913
+ if ((s = chart.getTitleText()) != null)
914
+ {
915
+ XLSXExporter.appendTitle(sb, s);
916
+ }
917
+ sb.push("<c:plotArea>");
918
+ sb.push("<c:layout/>");
919
+ if (chart.getChartType() != spreadsheet.ChartType.Unknown)
920
+ {
921
+ let nnaxis;
922
+ switch (chart.getChartType())
923
+ {
924
+ case spreadsheet.ChartType.LineChart:
925
+ sb.push("<c:lineChart>");
926
+ break;
927
+ case spreadsheet.ChartType.Unknown:
928
+ break;
929
+ }
930
+ m = 0;
931
+ n = chart.getSeriesCount();
932
+ while (m < n)
933
+ {
934
+ XLSXExporter.appendSeries(sb, chart.getSeriesNoCheck(m), m);
935
+ m++;
936
+ }
937
+ if ((nnaxis = chart.getCategoryAxis()) != null)
938
+ {
939
+ sb.push("<c:axId val=\"");
940
+ sb.push(""+chart.getAxisIndex(nnaxis));
941
+ sb.push("\"/>");
942
+ }
943
+ if ((nnaxis = chart.getValueAxis()) != null)
944
+ {
945
+ sb.push("<c:axId val=\"");
946
+ sb.push(""+ chart.getAxisIndex(nnaxis));
947
+ sb.push("\"/>");
948
+ }
949
+ switch (chart.getChartType())
950
+ {
951
+ case spreadsheet.ChartType.LineChart:
952
+ sb.push("</c:lineChart>");
953
+ break;
954
+ case spreadsheet.ChartType.Unknown:
955
+ break;
956
+ }
957
+ }
958
+ m = 0;
959
+ n = chart.getAxisCount();
960
+ while (m < n)
961
+ {
962
+ XLSXExporter.appendAxis(sb, chart.getAxis(m), m);
963
+ m++;
964
+ }
965
+ XLSXExporter.appendShapeProp(sb, chart.getShapeProp());
966
+ sb.push("</c:plotArea>");
967
+ if (chart.hasLegend())
968
+ {
969
+ sb.push("<c:legend>");
970
+ sb.push("<c:legendPos val=\"");
971
+ switch (chart.getLegendPos())
972
+ {
973
+ case spreadsheet.LegendPos.Bottom:
974
+ sb.push("b");
975
+ break;
976
+ }
977
+ sb.push("\"/>");
978
+ sb.push("<c:overlay val=\"");
979
+ if (chart.isLegendOverlay())
980
+ {
981
+ sb.push("true");
982
+ }
983
+ else
984
+ {
985
+ sb.push("false");
986
+ }
987
+ sb.push("\"/>");
988
+ sb.push("</c:legend>");
989
+ }
990
+ sb.push("<c:plotVisOnly val=\"true\"/>");
991
+ switch (chart.getDisplayBlankAs())
992
+ {
993
+ case spreadsheet.BlankAs.Default:
994
+ break;
995
+ case spreadsheet.BlankAs.Gap:
996
+ sb.push("<c:dispBlanksAs val=\"gap\"/>");
997
+ break;
998
+ case spreadsheet.BlankAs.Zero:
999
+ sb.push("<c:dispBlanksAs val=\"zero\"/>");
1000
+ break;
1001
+ }
1002
+ sb.push("</c:chart>");
1003
+ //////////////////////////////////////
1004
+ sb.push("</c:chartSpace>");
952
1005
 
953
- if (workbook.getStyleCount() > 0)
954
- {
955
- sb.push("<cellXfs count=\"");
956
- sb.push(""+workbook.getStyleCount());
957
- sb.push("\">");
958
- i = 0;
959
- k = workbook.getStyleCount();
960
- while (i < k)
961
- {
962
- let style;
963
- if ((style = workbook.getStyle(i)) != null)
964
- {
965
- XLSXExporter.appendXF(sb, style, borders, workbook, numFmtMap);
1006
+ if (!dirXlChart)
1007
+ {
1008
+ dirXlChart = true;
1009
+ zipFile.addDir("xl/charts/", ts, ts, ts, 0);
1010
+ }
1011
+ s = "xl/charts/chart" + chartCnt + ".xml";
1012
+ zipFile.addFile(s, new TextEncoder().encode(sb.join("")), ts, ts, ts, 0);
1013
+ sbContTypes.push("<Override PartName=\"/");
1014
+ sbContTypes.push(s);
1015
+ sbContTypes.push("\" ContentType=\"application/vnd.openxmlformats-officedocument.drawingml.chart+xml\"/>");
966
1016
  }
967
- i++;
1017
+ k++;
968
1018
  }
969
- sb.push("</cellXfs>");
970
1019
  }
971
-
972
- sb.push("<cellStyles count=\"6\">");
973
- sb.push("<cellStyle name=\"Normal\" xfId=\"0\" builtinId=\"0\"/>");
974
- sb.push("<cellStyle name=\"Comma\" xfId=\"15\" builtinId=\"3\"/>");
975
- sb.push("<cellStyle name=\"Comma [0]\" xfId=\"16\" builtinId=\"6\"/>");
976
- sb.push("<cellStyle name=\"Currency\" xfId=\"17\" builtinId=\"4\"/>");
977
- sb.push("<cellStyle name=\"Currency [0]\" xfId=\"18\" builtinId=\"7\"/>");
978
- sb.push("<cellStyle name=\"Percent\" xfId=\"19\" builtinId=\"5\"/>");
979
- sb.push("</cellStyles>");
1020
+ i++;
980
1021
  }
981
- sb.push("</styleSheet>");
982
- zipFile.addFile("xl/styles.xml", new TextEncoder().encode(sb.join("")), ts, ts, ts, 0);
983
- sbContTypes.push("<Override PartName=\"/xl/styles.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml\"/>");
984
-
1022
+
985
1023
  if (sharedStrings.length > 0)
986
1024
  {
987
1025
  sb = [];
988
- sb.push("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n");
1026
+ sb.push("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
989
1027
  sb.push("<sst xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" count=\"");
990
1028
  sb.push(""+sharedStrings.length);
991
1029
  sb.push("\" uniqueCount=\"");
@@ -1005,17 +1043,33 @@ export class XLSXExporter
1005
1043
  zipFile.addFile("xl/sharedStrings.xml", new TextEncoder().encode(sb.join("")), ts, ts, ts,0);
1006
1044
  sbContTypes.push("<Override PartName=\"/xl/sharedStrings.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml\"/>");
1007
1045
  }
1008
-
1046
+
1047
+ sb = [];
1048
+ sb.push("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
1049
+ sb.push("<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">");
1050
+ sb.push("<Relationship Id=\"rId1\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument\" Target=\"xl/workbook.xml\"/>");
1051
+ sb.push("<Relationship Id=\"rId2\" Type=\"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties\" Target=\"docProps/core.xml\"/>");
1052
+ sb.push("<Relationship Id=\"rId3\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties\" Target=\"docProps/app.xml\"/>");
1053
+ sb.push("\n</Relationships>");
1054
+ if (!dirRel)
1055
+ {
1056
+ zipFile.addDir("_rels/", ts, ts, ts, 0);
1057
+ dirRel = true;
1058
+ }
1059
+ zipFile.addFile("_rels/.rels", new TextEncoder().encode(sb.join("")), ts, ts, ts, 0);
1060
+ sbContTypes.push("<Override PartName=\"/_rels/.rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/>");
1061
+
1009
1062
  sb = [];
1010
1063
  sb.push("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
1011
1064
  sb.push("<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">");
1012
- sb.push("<Relationship Id=\"rId1\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles\" Target=\"styles.xml\"/>");
1065
+ sb.push("<Relationship Id=\"rId1\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme\" Target=\"theme/theme1.xml\"/>");
1066
+ sb.push("<Relationship Id=\"rId2\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles\" Target=\"styles.xml\"/>");
1013
1067
  i = 0;
1014
1068
  k = workbook.getCount();
1015
1069
  while (i < k)
1016
1070
  {
1017
1071
  sb.push("<Relationship Id=\"rId");
1018
- sb.push(""+(i + 2));
1072
+ sb.push(""+(i + 3));
1019
1073
  sb.push("\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet\" Target=\"worksheets/sheet");
1020
1074
  sb.push(""+(i + 1));
1021
1075
  sb.push(".xml\"/>");
@@ -1024,7 +1078,7 @@ export class XLSXExporter
1024
1078
  if (sharedStrings.length > 0)
1025
1079
  {
1026
1080
  sb.push("<Relationship Id=\"rId");
1027
- sb.push(""+(workbook.getCount() + 2));
1081
+ sb.push(""+(workbook.getCount() + 3));
1028
1082
  sb.push("\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings\" Target=\"sharedStrings.xml\"/>");
1029
1083
  }
1030
1084
  sb.push("\n</Relationships>");
@@ -1034,21 +1088,20 @@ export class XLSXExporter
1034
1088
  zipFile.addDir("xl/_rels/", ts, ts, ts, 0);
1035
1089
  }
1036
1090
  zipFile.addFile("xl/_rels/workbook.xml.rels", new TextEncoder().encode(sb.join("")), ts, ts, ts, 0);
1037
- sbContTypes.push("<Override PartName=\"/xl/_rels/workbook.xml.rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/>");
1038
-
1091
+
1039
1092
  sb = [];
1040
1093
  sb.push("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
1041
1094
  sb.push("<cp:coreProperties xmlns:cp=\"http://schemas.openxmlformats.org/package/2006/metadata/core-properties\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:dcmitype=\"http://purl.org/dc/dcmitype/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">");
1042
- sb.push("<dcterms:created xsi:type=\"dcterms:W3CDTF\">");
1043
1095
  t = workbook.getCreateTime();
1044
1096
  if (t)
1045
1097
  {
1098
+ sb.push("<dcterms:created xsi:type=\"dcterms:W3CDTF\">");
1046
1099
  sb.push(t.toString("yyyy-MM-dd"));
1047
1100
  sb.push('T');
1048
1101
  sb.push(t.toString("HH:mm:ss"));
1049
1102
  sb.push('Z');
1103
+ sb.push("</dcterms:created>");
1050
1104
  }
1051
- sb.push("</dcterms:created>");
1052
1105
  sb.push("<dc:creator>");
1053
1106
  if ((s = workbook.getAuthor()) != null)
1054
1107
  {
@@ -1080,16 +1133,16 @@ export class XLSXExporter
1080
1133
  sb.push(s);
1081
1134
  }
1082
1135
  sb.push("</cp:lastModifiedBy>");
1083
- sb.push("<dcterms:modified xsi:type=\"dcterms:W3CDTF\">");
1084
1136
  t = workbook.getModifyTime();
1085
1137
  if (t)
1086
1138
  {
1139
+ sb.push("<dcterms:modified xsi:type=\"dcterms:W3CDTF\">");
1087
1140
  sb.push(t.toString("yyyy-MM-dd"));
1088
1141
  sb.push('T');
1089
1142
  sb.push(t.toString("HH:mm:ss"));
1090
1143
  sb.push('Z');
1144
+ sb.push("</dcterms:modified>");
1091
1145
  }
1092
- sb.push("</dcterms:modified>");
1093
1146
  sb.push("<cp:revision>");
1094
1147
  sb.push(""+1);
1095
1148
  sb.push("</cp:revision>");
@@ -1120,6 +1173,7 @@ export class XLSXExporter
1120
1173
  sb.push("<Application>");
1121
1174
  sb.push("AVIRead/1.0");
1122
1175
  sb.push("</Application>");
1176
+ sb.push("<AppVersion>15.0000</AppVersion>");
1123
1177
  sb.push("</Properties>");
1124
1178
  zipFile.addFile("docProps/app.xml", new TextEncoder().encode(sb.join("")), ts, ts, ts, 0);
1125
1179
  sbContTypes.push("<Override PartName=\"/docProps/app.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.extended-properties+xml\"/>");