styled-exceljs 0.21.0 → 0.21.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -160,7 +160,7 @@ var DO_NOT_EXPORT_CODEPAGE = true;
160
160
  /*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false, DataView:false, Deno:false, Set:false, Float32Array:false */
161
161
  var XLSX = {};
162
162
  function make_xlsx_lib(XLSX){
163
- XLSX.version = '0.21.0';
163
+ XLSX.version = '0.21.2';
164
164
  var current_codepage = 1200, current_ansi = 1252;
165
165
  /*global cptable:true, window */
166
166
  var $cptable;
@@ -11266,7 +11266,7 @@ function resolve_style_obj_color(obj, themes) {
11266
11266
 
11267
11267
  /* 18.3.1.13 width calculations */
11268
11268
  /* [MS-OI29500] 2.1.595 Column Width & Formatting */
11269
- var DEF_MDW = 6, MAX_MDW = 15, MIN_MDW = 1, MDW = DEF_MDW;
11269
+ var DEF_MDW = 7, MAX_MDW = 15, MIN_MDW = 1, MDW = DEF_MDW;
11270
11270
  function width2px(width) { return Math.floor(( width + (Math.round(128/MDW))/256 )* MDW ); }
11271
11271
  function px2char(px) { return (Math.floor((px - 5)/MDW * 100 + 0.5))/100; }
11272
11272
  function char2width(chr) { return (Math.round((chr * MDW + 5)/MDW*256))/256; }
@@ -11308,6 +11308,188 @@ function process_col(coll) {
11308
11308
  if(coll.customWidth) delete coll.customWidth;
11309
11309
  }
11310
11310
 
11311
+ var XLSX_COL_WIDTH_MAX = 255, XLSX_COL_WIDTH_PADDING = 5;
11312
+ function clamp_col_width(width) {
11313
+ return width > XLSX_COL_WIDTH_MAX ? XLSX_COL_WIDTH_MAX : width < 0 ? 0 : width;
11314
+ }
11315
+ function px2col(px) {
11316
+ var width = char2width(px2char(Math.max(0, px)));
11317
+ return clamp_col_width(width);
11318
+ }
11319
+ function col2px(col) {
11320
+ if(!col) return 64;
11321
+ if(col.wpx != null) return col.wpx;
11322
+ if(col.width != null) return width2px(col.width);
11323
+ if(col.wch != null) return width2px(char2width(col.wch));
11324
+ return 64;
11325
+ }
11326
+ function set_col_width_from_px(col, px) {
11327
+ if(!col) col = ({});
11328
+ col.wpx = Math.max(0, Math.ceil(px));
11329
+ col.wch = px2char(col.wpx);
11330
+ col.width = px2col(col.wpx);
11331
+ col.MDW = MDW;
11332
+ col.bestFit = true;
11333
+ col.customWidth = true;
11334
+ return col;
11335
+ }
11336
+ function style_font_size_pt(style) {
11337
+ var font = style && style.font || {};
11338
+ var sz = +font.sz;
11339
+ return sz > 0 ? sz : 11;
11340
+ }
11341
+ function style_font_family(style) {
11342
+ var font = style && style.font || {};
11343
+ return font.name || "Calibri";
11344
+ }
11345
+ function css_font_from_style(style) {
11346
+ var font = style && style.font || {};
11347
+ var parts = [];
11348
+ if(font.italic) parts.push("italic");
11349
+ if(font.bold) parts.push("bold");
11350
+ parts.push(style_font_size_pt(style) + "pt");
11351
+ var name = style_font_family(style);
11352
+ if(/[,\s'"]/.test(name)) name = '"' + String(name).replace(/"/g, '\\"') + '"';
11353
+ parts.push(name);
11354
+ return parts.join(" ");
11355
+ }
11356
+ function fallback_char_width(ch, fpx) {
11357
+ var cc = ch.charCodeAt(0);
11358
+ if(cc == 9 || cc == 32) return fpx * 0.33;
11359
+ if(cc >= 48 && cc <= 57) return fpx * 0.52;
11360
+ if(cc >= 65 && cc <= 90) return fpx * 0.62;
11361
+ if(cc >= 97 && cc <= 122) {
11362
+ if("iljtfr".indexOf(ch) > -1) return fpx * 0.28;
11363
+ if("mw".indexOf(ch) > -1) return fpx * 0.82;
11364
+ return fpx * 0.50;
11365
+ }
11366
+ if(cc >= 0x2E80) return fpx;
11367
+ return fpx * 0.52;
11368
+ }
11369
+ function fallback_text_width(text, style) {
11370
+ var fpx = pt2px_browser(style_font_size_pt(style)), width = 0;
11371
+ for(var i = 0; i < text.length; ++i) width += fallback_char_width(text.charAt(i), fpx);
11372
+ return width;
11373
+ }
11374
+ function measure_text_width(text, style, opts) {
11375
+ var o = opts || {};
11376
+ var str = text == null ? "" : String(text);
11377
+ var lines = str.split(/\r\n|\n|\r/g), max = 0, i = 0, w = 0;
11378
+ if(o.measureText) for(i = 0; i < lines.length; ++i) {
11379
+ w = +o.measureText(lines[i], css_font_from_style(style), style || {});
11380
+ if(isFinite(w) && w > max) max = w;
11381
+ }
11382
+ else {
11383
+ var canvas = o.canvas, ctx = null;
11384
+ if(!canvas && typeof document !== "undefined" && document.createElement) try { canvas = document.createElement("canvas"); } catch(e) {}
11385
+ try { ctx = canvas && canvas.getContext && canvas.getContext("2d"); } catch(e) { ctx = null; }
11386
+ if(ctx && ctx.measureText) {
11387
+ ctx.font = css_font_from_style(style);
11388
+ for(i = 0; i < lines.length; ++i) {
11389
+ w = ctx.measureText(lines[i]).width;
11390
+ if(isFinite(w) && w > max) max = w;
11391
+ }
11392
+ } else for(i = 0; i < lines.length; ++i) {
11393
+ w = fallback_text_width(lines[i], style || {});
11394
+ if(isFinite(w) && w > max) max = w;
11395
+ }
11396
+ }
11397
+ return max;
11398
+ }
11399
+ function auto_fit_cell_text(cell, opts) {
11400
+ if(!cell || cell.v == null) return "";
11401
+ if(cell.w == null && cell.t != 'z') format_cell(cell);
11402
+ return String(cell.w != null ? cell.w : cell.v);
11403
+ }
11404
+ function text_width_segments(text, wrap) {
11405
+ var lines = String(text == null ? "" : text).split(/\r\n|\n|\r/g), out = [], i = 0, j = 0, parts = null;
11406
+ if(!wrap) return lines;
11407
+ for(i = 0; i < lines.length; ++i) {
11408
+ parts = lines[i].split(/[\t \u00A0\-\/]+/);
11409
+ for(j = 0; j < parts.length; ++j) if(parts[j]) out.push(parts[j]);
11410
+ if(!parts.length || (parts.length == 1 && !parts[0])) out.push(lines[i]);
11411
+ }
11412
+ return out.length ? out : [""];
11413
+ }
11414
+ function effective_cell_style(ws, cell, R, C) {
11415
+ var out = ({}), cols = ws["!cols"] || [], rows = ws["!rows"] || [];
11416
+ if(cols[C] && cols[C].s) extend_style_obj(out, cols[C].s);
11417
+ if(rows[R] && rows[R].s) extend_style_obj(out, rows[R].s);
11418
+ if(cell && cell.s) extend_style_obj(out, cell.s);
11419
+ return out;
11420
+ }
11421
+ function measure_cell_text_width(cell, style, opts) {
11422
+ var o = opts || {}, text = auto_fit_cell_text(cell, o), align = style && style.alignment || {};
11423
+ var wrap = !!align.wrapText, segments = text_width_segments(text, wrap), max = 0, w = 0;
11424
+ for(var i = 0; i < segments.length; ++i) {
11425
+ w = measure_text_width(segments[i], style, o);
11426
+ if(w > max) max = w;
11427
+ }
11428
+ var indent = +align.indent || 0;
11429
+ if(indent > 0) max += indent * 3 * Math.max(1, MDW);
11430
+ var rotation = +align.textRotation || 0;
11431
+ if(rotation == 255) rotation = 90;
11432
+ if(rotation > 90) rotation = 90 - rotation;
11433
+ if(rotation < 0) rotation = -rotation;
11434
+ if(rotation > 0 && rotation < 90) {
11435
+ var rad = rotation * Math.PI / 180, fpx = pt2px_browser(style_font_size_pt(style));
11436
+ max = Math.abs(max * Math.cos(rad)) + Math.abs(fpx * Math.sin(rad));
11437
+ } else if(rotation >= 90) max = Math.max(MDW + XLSX_COL_WIDTH_PADDING, pt2px_browser(style_font_size_pt(style)) + 2);
11438
+ return max + (o.padding != null ? +o.padding : XLSX_COL_WIDTH_PADDING);
11439
+ }
11440
+ function merge_start_map(merges) {
11441
+ var out = {};
11442
+ for(var i = 0; i < merges.length; ++i) out[merges[i].s.r + ":" + merges[i].s.c] = merges[i];
11443
+ return out;
11444
+ }
11445
+ function is_covered_merge(merges, R, C) {
11446
+ for(var i = 0; i < merges.length; ++i) {
11447
+ var m = merges[i];
11448
+ if(m.s.r <= R && R <= m.e.r && m.s.c <= C && C <= m.e.c) return !(m.s.r == R && m.s.c == C);
11449
+ }
11450
+ return false;
11451
+ }
11452
+ function auto_fit_columns(ws, opts) {
11453
+ var o = opts || {}, oldMDW = MDW;
11454
+ if(o.MDW) MDW = +o.MDW || MDW;
11455
+ var r = o.range ? (typeof o.range == "string" ? decode_range(o.range) : o.range) : decode_range(ws["!ref"] || "A1");
11456
+ var base = ws["!cols"] || [], rows = ws["!rows"] || [], cols = [], widths = [];
11457
+ var minpx = o.minPx != null ? +o.minPx : o.min != null ? width2px(char2width(+o.min)) : 0;
11458
+ var maxpx = o.maxPx != null ? +o.maxPx : width2px(XLSX_COL_WIDTH_MAX);
11459
+ var merges = o.includeMerged === false ? [] : (ws["!merges"] || []);
11460
+ var starts = merge_start_map(merges), dense = ws["!data"] != null;
11461
+ var C = 0, R = 0, span = 0, m = null, j = 0, cell = null, style = null, need = 0, have = 0;
11462
+ for(C = r.s.c; C <= r.e.c; ++C) {
11463
+ cols[C] = dup(base[C] || {});
11464
+ if(cols[C] && cols[C].hidden && o.skipHidden) continue;
11465
+ widths[C] = cols[C] && (cols[C].wpx != null || cols[C].width != null || cols[C].wch != null) ? col2px(cols[C]) : minpx;
11466
+ }
11467
+ for(R = r.s.r; R <= r.e.r; ++R) {
11468
+ if(rows[R] && rows[R].hidden && o.skipHidden) continue;
11469
+ for(C = r.s.c; C <= r.e.c; ++C) {
11470
+ if(cols[C] && cols[C].hidden && o.skipHidden) continue;
11471
+ if(is_covered_merge(merges, R, C)) continue;
11472
+ cell = dense ? (ws["!data"][R]||[])[C] : ws[encode_cell({r:R,c:C})];
11473
+ if(!cell || cell.v == null) continue;
11474
+ style = effective_cell_style(ws, cell, R, C);
11475
+ need = measure_cell_text_width(cell, style, o);
11476
+ if(style && style.alignment && style.alignment.shrinkToFit && widths[C]) need = Math.min(need, widths[C]);
11477
+ m = starts[R + ":" + C];
11478
+ span = m ? m.e.c - m.s.c + 1 : 1;
11479
+ if(span > 1) {
11480
+ have = 0;
11481
+ for(j = 0; j < span; ++j) have += widths[C+j] || minpx;
11482
+ if(need > have) for(j = 0; j < span; ++j) widths[C+j] = Math.min(maxpx, Math.max(widths[C+j] || minpx, (widths[C+j] || minpx) + (need - have) / span));
11483
+ } else widths[C] = Math.min(maxpx, Math.max(widths[C] || minpx, need));
11484
+ }
11485
+ }
11486
+ for(C = r.s.c; C <= r.e.c; ++C) if(widths[C] != null) cols[C] = set_col_width_from_px(cols[C] || {}, Math.min(maxpx, Math.max(minpx, widths[C])));
11487
+ if(o.set === false) { MDW = oldMDW; return cols; }
11488
+ ws["!cols"] = cols;
11489
+ MDW = oldMDW;
11490
+ return cols;
11491
+ }
11492
+
11311
11493
  var DEF_PPI = 96, PPI = DEF_PPI;
11312
11494
  function px2pt(px) { return px * 96 / PPI; }
11313
11495
  function pt2px(pt) { return pt * PPI / 96; }
@@ -16364,8 +16546,11 @@ function col_obj_w(C, col) {
16364
16546
  else if(col.wch != null) wch = col.wch;
16365
16547
  if(wch > -1) { p.width = char2width(wch); p.customWidth = 1; }
16366
16548
  else if(col.width != null) p.width = col.width;
16549
+ if(p.width != null) p.width = clamp_col_width(p.width);
16367
16550
  if(col.hidden) p.hidden = true;
16368
16551
  if(col.level != null) { p.outlineLevel = p.level = col.level; }
16552
+ if(col.bestFit || col.bestfit) p.bestFit = true;
16553
+ if(col.customWidth || col.customwidth) p.customWidth = 1;
16369
16554
  return p;
16370
16555
  }
16371
16556
 
@@ -16723,10 +16908,13 @@ function parse_ws_xml_cols(columns, cols) {
16723
16908
  for(var coli = 0; coli != cols.length; ++coli) {
16724
16909
  var coll = parsexmltag(cols[coli], true);
16725
16910
  if(coll.hidden) coll.hidden = parsexmlbool(coll.hidden);
16911
+ if(coll.bestFit) coll.bestFit = parsexmlbool(coll.bestFit);
16912
+ if(coll.customWidth) coll.customWidth = parsexmlbool(coll.customWidth);
16726
16913
  var colm=parseInt(coll.min, 10)-1, colM=parseInt(coll.max,10)-1;
16727
16914
  if(coll.outlineLevel) coll.level = (+coll.outlineLevel || 0);
16728
16915
  delete coll.min; delete coll.max; coll.width = +coll.width;
16729
- if(!seencol && coll.width) { seencol = true; find_mdw_colw(coll.width); }
16916
+ /* OOXML widths share the workbook Normal-font MDW; do not infer a different scale per sheet. */
16917
+ if(!seencol && coll.width) { seencol = true; MDW = DEF_MDW; }
16730
16918
  process_col(coll);
16731
16919
  while(colm <= colM) columns[colm++] = dup(coll);
16732
16920
  }
@@ -17896,7 +18084,7 @@ function parse_ws_bin(data, _opts, idx, rels, wb, themes, styles) {
17896
18084
  if(!opts.cellStyles) break;
17897
18085
  while(val.e >= val.s) {
17898
18086
  colinfo[val.e--] = { width: val.w/256, hidden: !!(val.flags & 0x01), level: val.level };
17899
- if(!seencol) { seencol = true; find_mdw_colw(val.w/256); }
18087
+ if(!seencol) { seencol = true; MDW = DEF_MDW; }
17900
18088
  process_col(colinfo[val.e+1]);
17901
18089
  }
17902
18090
  break;
@@ -21436,7 +21624,7 @@ wb.opts.Date1904 = Workbook.WBProps.date1904 = val; break;
21436
21624
  while(val.e >= val.s) {
21437
21625
  colinfo[val.e--] = { width: val.w/256, level: (val.level || 0), hidden: !!(val.flags & 1) };
21438
21626
  if(val.ixfe != null && XFs[val.ixfe]) colinfo[val.e+1].s = resolve_xls_style(XFs[val.ixfe], val.ixfe);
21439
- if(!seencol) { seencol = true; find_mdw_colw(val.w/256); }
21627
+ if(!seencol) { seencol = true; MDW = DEF_MDW; }
21440
21628
  process_col(colinfo[val.e+1]);
21441
21629
  }
21442
21630
  } break;
@@ -23864,8 +24052,6 @@ function html_cell_style(cell, opts) {
23864
24052
  var alignment = s.alignment || {};
23865
24053
  if(alignment.horizontal) css.push("text-align:" + alignment.horizontal);
23866
24054
  if(alignment.vertical) css.push("vertical-align:" + alignment.vertical);
23867
- if(alignment.wrapText) css.push("white-space:normal");
23868
- if(alignment.shrinkToFit) css.push("font-size:smaller");
23869
24055
  if(alignment.textRotation != null && alignment.textRotation !== 0) {
23870
24056
  var deg = alignment.textRotation == 255 ? 90 : alignment.textRotation > 90 ? 90 - alignment.textRotation : alignment.textRotation;
23871
24057
  css.push("transform:rotate(" + deg + "deg)");
@@ -23878,12 +24064,29 @@ function html_cell_style(cell, opts) {
23878
24064
  add_html_border(css, "bottom", border.bottom);
23879
24065
  return css.join(";");
23880
24066
  }
24067
+ function html_cell_layout_style(cell, opts, C, CS, cols) {
24068
+ if(!opts || !cell) return "";
24069
+ var s = cell.s || {}, alignment = s.alignment || {}, css = [];
24070
+ if(opts.browserPixels || opts.autoFit) css.push("box-sizing:border-box;padding:0 2px;min-width:0");
24071
+ if(alignment.wrapText) css.push("white-space:pre-wrap;overflow-wrap:normal;word-break:normal");
24072
+ else {
24073
+ css.push("white-space:pre");
24074
+ if(alignment.shrinkToFit || opts.overflow == "clip" || opts.overflow == "hidden") css.push("overflow:hidden;text-overflow:clip");
24075
+ else css.push("overflow:visible");
24076
+ }
24077
+ if(alignment.shrinkToFit && cols && C != null) {
24078
+ var have = 0, span = CS || 1;
24079
+ for(var j = 0; j < span; ++j) have += html_col_width(cols[C+j]);
24080
+ var need = measure_cell_text_width(cell, s, opts);
24081
+ if(have > 0 && need > have) {
24082
+ var scale = Math.max(0.25, Math.min(1, have / need));
24083
+ css.push("font-size:" + Math.max(1, style_font_size_pt(s) * scale) + "pt");
24084
+ }
24085
+ }
24086
+ return css.join(";");
24087
+ }
23881
24088
  function html_col_width(col) {
23882
- if(!col) return 64;
23883
- if(col.wpx != null) return col.wpx;
23884
- if(col.width != null) return width2px(col.width);
23885
- if(col.wch != null) return width2px(char2width(col.wch));
23886
- return 64;
24089
+ return col2px(col);
23887
24090
  }
23888
24091
  function html_row_height(row) {
23889
24092
  if(!row) return 20;
@@ -23898,7 +24101,7 @@ function make_html_row(ws, r, R, o) {
23898
24101
  var sp = ({});
23899
24102
  var dense = ws["!data"] != null;
23900
24103
  var row = (ws["!rows"]||[])[R];
23901
- var cols = ws["!cols"] || [];
24104
+ var cols = o && o._htmlCols || ws["!cols"] || [];
23902
24105
  for(var C = r.s.c; C <= r.e.c; ++C) {
23903
24106
  var RS = 0, CS = 0;
23904
24107
  for(var j = 0; j < M.length; ++j) {
@@ -23941,6 +24144,8 @@ function make_html_row(ws, r, R, o) {
23941
24144
  if(cell.l && (cell.l.Target || "#").charAt(0) != "#" && (!o.sanitizeLinks || (cell.l.Target || "").slice(0, 11).toLowerCase() != 'javascript:')) w = '<a href="' + escapehtml(cell.l.Target) +'">' + w + '</a>';
23942
24145
  }
23943
24146
  var cstyle = html_cell_style(stylecell, o);
24147
+ var lstyle = html_cell_layout_style(stylecell, o, C, CS, cols);
24148
+ if(lstyle) cstyle = cstyle ? cstyle + ";" + lstyle : lstyle;
23944
24149
  if(cstyle) sp.style = cstyle;
23945
24150
  sp.id = (o.id || "sjs") + "-" + coord;
23946
24151
  oo.push(writextag('td', w, sp));
@@ -23972,9 +24177,9 @@ function html_to_workbook(str, opts) {
23972
24177
  }
23973
24178
 
23974
24179
  var HTML_EMU_PER_PIXEL = 9525;
23975
- function html_anchor_pos(ws, anchor) {
24180
+ function html_anchor_pos(ws, anchor, opts) {
23976
24181
  var out = {left:0, top:0, width:480, height:288};
23977
- var cols = ws["!cols"] || [], rows = ws["!rows"] || [];
24182
+ var cols = opts && opts._htmlCols || ws["!cols"] || [], rows = ws["!rows"] || [];
23978
24183
  var from = anchor && anchor.from || {col:0,row:0,colOff:0,rowOff:0};
23979
24184
  var to = anchor && anchor.to;
23980
24185
  for(var C = 0; C < (from.col||0); ++C) out.left += html_col_width(cols[C]);
@@ -24087,11 +24292,11 @@ function render_html_drawings(ws, opts) {
24087
24292
  var out = [], drawings = ws["!drawings"] || {}, charts = ws["!charts"] || [];
24088
24293
  if(opts && opts.drawings && drawings.images) drawings.images.forEach(function(img) {
24089
24294
  if(!img || !img.dataURI) return;
24090
- var pos = html_anchor_pos(ws, img.anchor);
24295
+ var pos = html_anchor_pos(ws, img.anchor, opts);
24091
24296
  out.push('<img class="sjs-drawing-image" src="' + img.dataURI + '" style="' + html_abs_style(pos) + '"/>');
24092
24297
  });
24093
24298
  if(opts && opts.charts) charts.forEach(function(chart) {
24094
- var pos = html_anchor_pos(ws, chart.anchor);
24299
+ var pos = html_anchor_pos(ws, chart.anchor, opts);
24095
24300
  out.push('<div class="sjs-chart" style="' + html_abs_style(pos) + '">' + render_chart_svg(chart, pos.width, pos.height) + '</div>');
24096
24301
  });
24097
24302
  if(!out.length) return "";
@@ -24099,11 +24304,16 @@ function render_html_drawings(ws, opts) {
24099
24304
  }
24100
24305
  function make_html_preamble(ws, R, o) {
24101
24306
  var out = [];
24102
- var table = '<table' + (o && o.id ? ' id="' + o.id + '"' : "") + '>';
24103
- if(o && o.browserPixels && ws["!cols"]) {
24307
+ var tattr = ({}), tstyle = [];
24308
+ if(o && o.id) tattr.id = o.id;
24309
+ if(o && (o.browserPixels || o.autoFit)) tstyle.push("border-collapse:collapse;table-layout:fixed");
24310
+ if(tstyle.length) tattr.style = tstyle.join(";");
24311
+ var table = writextag("table", "", tattr).replace(/<\/table>$/, "");
24312
+ var cols = o && o._htmlCols || ws["!cols"];
24313
+ if(o && (o.browserPixels || o.autoFit) && cols) {
24104
24314
  out.push("<colgroup>");
24105
24315
  for(var C = R.s.c; C <= R.e.c; ++C) {
24106
- var col = ws["!cols"][C], style = [];
24316
+ var col = cols[C], style = [];
24107
24317
  style.push("width:" + html_col_width(col) + "px");
24108
24318
  if(col && col.hidden) style.push("display:none");
24109
24319
  out.push(writextag("col", null, {style:style.join(";")}));
@@ -24114,7 +24324,16 @@ function make_html_preamble(ws, R, o) {
24114
24324
  }
24115
24325
 
24116
24326
  function sheet_to_html(ws, opts/*, wb:?Workbook*/) {
24117
- var o = opts || {};
24327
+ var o = {};
24328
+ if(opts) for(var k in opts) if(Object.prototype.hasOwnProperty.call(opts, k)) o[k] = opts[k];
24329
+ if(o.autoFit) {
24330
+ var af = {set:false};
24331
+ if(typeof o.autoFit == "object") for(k in o.autoFit) if(Object.prototype.hasOwnProperty.call(o.autoFit, k)) af[k] = o.autoFit[k];
24332
+ if(o.measureText && af.measureText == null) af.measureText = o.measureText;
24333
+ if(o.canvas && af.canvas == null) af.canvas = o.canvas;
24334
+ o._htmlCols = auto_fit_columns(ws, af);
24335
+ if(o.browserPixels == null) o.browserPixels = true;
24336
+ }
24118
24337
  var header = o.header != null ? o.header : HTML_BEGIN;
24119
24338
  var footer = o.footer != null ? o.footer : HTML_END;
24120
24339
  var out = [header];
@@ -26049,7 +26268,8 @@ var numbers_lut_new = function() {
26049
26268
  function numbers_format_cell(cell, t, flags, ofmt, nfmt) {
26050
26269
  var _a, _b, _c, _d;
26051
26270
  var ctype = t & 255, ver = t >> 8;
26052
- var fmt = ver >= 5 ? nfmt : ofmt;
26271
+ /* Missing legacy/new format tables mean the default format. */
26272
+ var fmt = (ver >= 5 ? nfmt : ofmt) || [];
26053
26273
  dur:
26054
26274
  if (flags & (ver > 4 ? 8 : 4) && cell.t == "n" && ctype == 7) {
26055
26275
  var dstyle = ((_a = fmt[7]) == null ? void 0 : _a[0]) ? varint_to_i32(fmt[7][0].data) : -1;
@@ -27964,6 +28184,7 @@ function drawing_mime(path) {
27964
28184
  case "bmp": return "image/bmp";
27965
28185
  case "svg": return "image/svg+xml";
27966
28186
  case "jpg": case "jpeg": return "image/jpeg";
28187
+ case "tif": case "tiff": return "image/tiff";
27967
28188
  default: return "application/octet-stream";
27968
28189
  }
27969
28190
  }
@@ -27979,7 +28200,9 @@ function parse_sheet_drawing(sheet, type, zip, path, idx, opts, wb) {
27979
28200
  if(!img || !img.target) return;
27980
28201
  var ipath = resolve_path(img.target, dfile);
27981
28202
  var ibin = getzipbin(zip, ipath, true);
27982
- if(ibin) img.dataURI = "data:" + drawing_mime(ipath) + ";base64," + Base64_encode_arr(ibin);
28203
+ var contentType = drawing_mime(ipath);
28204
+ if(ibin) img.dataURI = "data:" + contentType + ";base64," + Base64_encode_arr(ibin);
28205
+ img.contentType = contentType;
27983
28206
  img.path = ipath;
27984
28207
  });
27985
28208
  if(opts.charts && draw.charts && draw.charts.length) {
@@ -29342,6 +29565,9 @@ var utils = {
29342
29565
  sheet_to_formulae: sheet_to_formulae,
29343
29566
  sheet_to_row_object_array: sheet_to_json,
29344
29567
  validate_merges: validate_merges,
29568
+ measure_text_width: measure_text_width,
29569
+ auto_fit_columns: auto_fit_columns,
29570
+ autofit_columns: auto_fit_columns,
29345
29571
  col_width_to_px: width2px,
29346
29572
  px_to_col_width: function(px) { return char2width(px2char(px)); },
29347
29573
  row_height_to_px: pt2px_browser,