styled-exceljs 0.21.0 → 0.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/README.md +8 -2
- package/bower.json +1 -1
- package/dist/xlsx.core.min.js +18 -18
- package/dist/xlsx.core.min.map +1 -1
- package/dist/xlsx.extendscript.js +238 -17
- package/dist/xlsx.full.min.js +17 -17
- package/dist/xlsx.full.min.map +1 -1
- package/dist/xlsx.mini.min.js +10 -10
- package/dist/xlsx.mini.min.map +1 -1
- package/docs/visual-fidelity.md +38 -2
- package/docs/visual-fidelity.zh-CN.md +35 -1
- package/package.json +1 -1
- package/types/index.d.ts +53 -0
- package/xlsx.js +238 -17
- package/xlsx.mjs +238 -17
|
@@ -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.
|
|
163
|
+
XLSX.version = '0.21.1';
|
|
164
164
|
var current_codepage = 1200, current_ansi = 1252;
|
|
165
165
|
/*global cptable:true, window */
|
|
166
166
|
var $cptable;
|
|
@@ -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,6 +16908,8 @@ 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;
|
|
@@ -23864,8 +24051,6 @@ function html_cell_style(cell, opts) {
|
|
|
23864
24051
|
var alignment = s.alignment || {};
|
|
23865
24052
|
if(alignment.horizontal) css.push("text-align:" + alignment.horizontal);
|
|
23866
24053
|
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
24054
|
if(alignment.textRotation != null && alignment.textRotation !== 0) {
|
|
23870
24055
|
var deg = alignment.textRotation == 255 ? 90 : alignment.textRotation > 90 ? 90 - alignment.textRotation : alignment.textRotation;
|
|
23871
24056
|
css.push("transform:rotate(" + deg + "deg)");
|
|
@@ -23878,12 +24063,29 @@ function html_cell_style(cell, opts) {
|
|
|
23878
24063
|
add_html_border(css, "bottom", border.bottom);
|
|
23879
24064
|
return css.join(";");
|
|
23880
24065
|
}
|
|
24066
|
+
function html_cell_layout_style(cell, opts, C, CS, cols) {
|
|
24067
|
+
if(!opts || !cell) return "";
|
|
24068
|
+
var s = cell.s || {}, alignment = s.alignment || {}, css = [];
|
|
24069
|
+
if(opts.browserPixels || opts.autoFit) css.push("box-sizing:border-box;padding:0 2px;min-width:0");
|
|
24070
|
+
if(alignment.wrapText) css.push("white-space:pre-wrap;overflow-wrap:normal;word-break:normal");
|
|
24071
|
+
else {
|
|
24072
|
+
css.push("white-space:pre");
|
|
24073
|
+
if(alignment.shrinkToFit || opts.overflow == "clip" || opts.overflow == "hidden") css.push("overflow:hidden;text-overflow:clip");
|
|
24074
|
+
else css.push("overflow:visible");
|
|
24075
|
+
}
|
|
24076
|
+
if(alignment.shrinkToFit && cols && C != null) {
|
|
24077
|
+
var have = 0, span = CS || 1;
|
|
24078
|
+
for(var j = 0; j < span; ++j) have += html_col_width(cols[C+j]);
|
|
24079
|
+
var need = measure_cell_text_width(cell, s, opts);
|
|
24080
|
+
if(have > 0 && need > have) {
|
|
24081
|
+
var scale = Math.max(0.25, Math.min(1, have / need));
|
|
24082
|
+
css.push("font-size:" + Math.max(1, style_font_size_pt(s) * scale) + "pt");
|
|
24083
|
+
}
|
|
24084
|
+
}
|
|
24085
|
+
return css.join(";");
|
|
24086
|
+
}
|
|
23881
24087
|
function html_col_width(col) {
|
|
23882
|
-
|
|
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;
|
|
24088
|
+
return col2px(col);
|
|
23887
24089
|
}
|
|
23888
24090
|
function html_row_height(row) {
|
|
23889
24091
|
if(!row) return 20;
|
|
@@ -23898,7 +24100,7 @@ function make_html_row(ws, r, R, o) {
|
|
|
23898
24100
|
var sp = ({});
|
|
23899
24101
|
var dense = ws["!data"] != null;
|
|
23900
24102
|
var row = (ws["!rows"]||[])[R];
|
|
23901
|
-
var cols = ws["!cols"] || [];
|
|
24103
|
+
var cols = o && o._htmlCols || ws["!cols"] || [];
|
|
23902
24104
|
for(var C = r.s.c; C <= r.e.c; ++C) {
|
|
23903
24105
|
var RS = 0, CS = 0;
|
|
23904
24106
|
for(var j = 0; j < M.length; ++j) {
|
|
@@ -23941,6 +24143,8 @@ function make_html_row(ws, r, R, o) {
|
|
|
23941
24143
|
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
24144
|
}
|
|
23943
24145
|
var cstyle = html_cell_style(stylecell, o);
|
|
24146
|
+
var lstyle = html_cell_layout_style(stylecell, o, C, CS, cols);
|
|
24147
|
+
if(lstyle) cstyle = cstyle ? cstyle + ";" + lstyle : lstyle;
|
|
23944
24148
|
if(cstyle) sp.style = cstyle;
|
|
23945
24149
|
sp.id = (o.id || "sjs") + "-" + coord;
|
|
23946
24150
|
oo.push(writextag('td', w, sp));
|
|
@@ -23972,9 +24176,9 @@ function html_to_workbook(str, opts) {
|
|
|
23972
24176
|
}
|
|
23973
24177
|
|
|
23974
24178
|
var HTML_EMU_PER_PIXEL = 9525;
|
|
23975
|
-
function html_anchor_pos(ws, anchor) {
|
|
24179
|
+
function html_anchor_pos(ws, anchor, opts) {
|
|
23976
24180
|
var out = {left:0, top:0, width:480, height:288};
|
|
23977
|
-
var cols = ws["!cols"] || [], rows = ws["!rows"] || [];
|
|
24181
|
+
var cols = opts && opts._htmlCols || ws["!cols"] || [], rows = ws["!rows"] || [];
|
|
23978
24182
|
var from = anchor && anchor.from || {col:0,row:0,colOff:0,rowOff:0};
|
|
23979
24183
|
var to = anchor && anchor.to;
|
|
23980
24184
|
for(var C = 0; C < (from.col||0); ++C) out.left += html_col_width(cols[C]);
|
|
@@ -24087,11 +24291,11 @@ function render_html_drawings(ws, opts) {
|
|
|
24087
24291
|
var out = [], drawings = ws["!drawings"] || {}, charts = ws["!charts"] || [];
|
|
24088
24292
|
if(opts && opts.drawings && drawings.images) drawings.images.forEach(function(img) {
|
|
24089
24293
|
if(!img || !img.dataURI) return;
|
|
24090
|
-
var pos = html_anchor_pos(ws, img.anchor);
|
|
24294
|
+
var pos = html_anchor_pos(ws, img.anchor, opts);
|
|
24091
24295
|
out.push('<img class="sjs-drawing-image" src="' + img.dataURI + '" style="' + html_abs_style(pos) + '"/>');
|
|
24092
24296
|
});
|
|
24093
24297
|
if(opts && opts.charts) charts.forEach(function(chart) {
|
|
24094
|
-
var pos = html_anchor_pos(ws, chart.anchor);
|
|
24298
|
+
var pos = html_anchor_pos(ws, chart.anchor, opts);
|
|
24095
24299
|
out.push('<div class="sjs-chart" style="' + html_abs_style(pos) + '">' + render_chart_svg(chart, pos.width, pos.height) + '</div>');
|
|
24096
24300
|
});
|
|
24097
24301
|
if(!out.length) return "";
|
|
@@ -24099,11 +24303,16 @@ function render_html_drawings(ws, opts) {
|
|
|
24099
24303
|
}
|
|
24100
24304
|
function make_html_preamble(ws, R, o) {
|
|
24101
24305
|
var out = [];
|
|
24102
|
-
var
|
|
24103
|
-
if(o && o.
|
|
24306
|
+
var tattr = ({}), tstyle = [];
|
|
24307
|
+
if(o && o.id) tattr.id = o.id;
|
|
24308
|
+
if(o && (o.browserPixels || o.autoFit)) tstyle.push("border-collapse:collapse;table-layout:fixed");
|
|
24309
|
+
if(tstyle.length) tattr.style = tstyle.join(";");
|
|
24310
|
+
var table = writextag("table", "", tattr).replace(/<\/table>$/, "");
|
|
24311
|
+
var cols = o && o._htmlCols || ws["!cols"];
|
|
24312
|
+
if(o && (o.browserPixels || o.autoFit) && cols) {
|
|
24104
24313
|
out.push("<colgroup>");
|
|
24105
24314
|
for(var C = R.s.c; C <= R.e.c; ++C) {
|
|
24106
|
-
var col =
|
|
24315
|
+
var col = cols[C], style = [];
|
|
24107
24316
|
style.push("width:" + html_col_width(col) + "px");
|
|
24108
24317
|
if(col && col.hidden) style.push("display:none");
|
|
24109
24318
|
out.push(writextag("col", null, {style:style.join(";")}));
|
|
@@ -24114,7 +24323,16 @@ function make_html_preamble(ws, R, o) {
|
|
|
24114
24323
|
}
|
|
24115
24324
|
|
|
24116
24325
|
function sheet_to_html(ws, opts/*, wb:?Workbook*/) {
|
|
24117
|
-
var o =
|
|
24326
|
+
var o = {};
|
|
24327
|
+
if(opts) for(var k in opts) if(Object.prototype.hasOwnProperty.call(opts, k)) o[k] = opts[k];
|
|
24328
|
+
if(o.autoFit) {
|
|
24329
|
+
var af = {set:false};
|
|
24330
|
+
if(typeof o.autoFit == "object") for(k in o.autoFit) if(Object.prototype.hasOwnProperty.call(o.autoFit, k)) af[k] = o.autoFit[k];
|
|
24331
|
+
if(o.measureText && af.measureText == null) af.measureText = o.measureText;
|
|
24332
|
+
if(o.canvas && af.canvas == null) af.canvas = o.canvas;
|
|
24333
|
+
o._htmlCols = auto_fit_columns(ws, af);
|
|
24334
|
+
if(o.browserPixels == null) o.browserPixels = true;
|
|
24335
|
+
}
|
|
24118
24336
|
var header = o.header != null ? o.header : HTML_BEGIN;
|
|
24119
24337
|
var footer = o.footer != null ? o.footer : HTML_END;
|
|
24120
24338
|
var out = [header];
|
|
@@ -29342,6 +29560,9 @@ var utils = {
|
|
|
29342
29560
|
sheet_to_formulae: sheet_to_formulae,
|
|
29343
29561
|
sheet_to_row_object_array: sheet_to_json,
|
|
29344
29562
|
validate_merges: validate_merges,
|
|
29563
|
+
measure_text_width: measure_text_width,
|
|
29564
|
+
auto_fit_columns: auto_fit_columns,
|
|
29565
|
+
autofit_columns: auto_fit_columns,
|
|
29345
29566
|
col_width_to_px: width2px,
|
|
29346
29567
|
px_to_col_width: function(px) { return char2width(px2char(px)); },
|
|
29347
29568
|
row_height_to_px: pt2px_browser,
|