styled-exceljs 0.21.1 → 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.
@@ -1,5 +1,9 @@
1
1
  # XLSX / XLS Visual Fidelity Extensions
2
2
 
3
+ `styled-exceljs` is built from a fork of the original SheetJS Community Edition
4
+ source code. The fork keeps SheetJS-compatible APIs and extends the original
5
+ reader / writer foundation with visual parsing and browser rendering features.
6
+
3
7
  This document describes the browser rendering metadata exposed by this build.
4
8
  The public model extends the existing SheetJS worksheet object and keeps default
5
9
  read behavior compatible. Expensive visual parsing is enabled with explicit
@@ -1,5 +1,8 @@
1
1
  # XLSX / XLS 视觉保真扩展
2
2
 
3
+ `styled-exceljs` 基于 SheetJS Community Edition 原始代码 fork 并继续增强。
4
+ 本 fork 保持 SheetJS 兼容 API 和读写基础,在此之上扩展视觉解析和浏览器渲染能力。
5
+
3
6
  本文档说明本版本在 SheetJS 兼容工作表模型上新增的浏览器渲染元数据。
4
7
  默认读取行为保持轻量和兼容;完整视觉信息需要通过显式选项启用。
5
8
 
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "styled-exceljs",
3
- "version": "0.21.1",
3
+ "version": "0.21.2",
4
4
  "author": "sheetjs",
5
- "description": "SheetJS Spreadsheet data parser and writer",
5
+ "description": "SheetJS CE fork with enhanced XLS/XLSX styling and browser rendering",
6
6
  "keywords": [
7
7
  "excel",
8
8
  "xls",
package/xlsx.js CHANGED
@@ -4,7 +4,7 @@
4
4
  /*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false, DataView:false, Deno:false, Set:false, Float32Array:false */
5
5
  var XLSX = {};
6
6
  function make_xlsx_lib(XLSX){
7
- XLSX.version = '0.21.1';
7
+ XLSX.version = '0.21.2';
8
8
  var current_codepage = 1200, current_ansi = 1252;
9
9
  /*global cptable:true, window */
10
10
  var $cptable;
@@ -11110,7 +11110,7 @@ function resolve_style_obj_color(obj, themes) {
11110
11110
 
11111
11111
  /* 18.3.1.13 width calculations */
11112
11112
  /* [MS-OI29500] 2.1.595 Column Width & Formatting */
11113
- var DEF_MDW = 6, MAX_MDW = 15, MIN_MDW = 1, MDW = DEF_MDW;
11113
+ var DEF_MDW = 7, MAX_MDW = 15, MIN_MDW = 1, MDW = DEF_MDW;
11114
11114
  function width2px(width) { return Math.floor(( width + (Math.round(128/MDW))/256 )* MDW ); }
11115
11115
  function px2char(px) { return (Math.floor((px - 5)/MDW * 100 + 0.5))/100; }
11116
11116
  function char2width(chr) { return (Math.round((chr * MDW + 5)/MDW*256))/256; }
@@ -16757,7 +16757,8 @@ function parse_ws_xml_cols(columns, cols) {
16757
16757
  var colm=parseInt(coll.min, 10)-1, colM=parseInt(coll.max,10)-1;
16758
16758
  if(coll.outlineLevel) coll.level = (+coll.outlineLevel || 0);
16759
16759
  delete coll.min; delete coll.max; coll.width = +coll.width;
16760
- if(!seencol && coll.width) { seencol = true; find_mdw_colw(coll.width); }
16760
+ /* OOXML widths share the workbook Normal-font MDW; do not infer a different scale per sheet. */
16761
+ if(!seencol && coll.width) { seencol = true; MDW = DEF_MDW; }
16761
16762
  process_col(coll);
16762
16763
  while(colm <= colM) columns[colm++] = dup(coll);
16763
16764
  }
@@ -17927,7 +17928,7 @@ function parse_ws_bin(data, _opts, idx, rels, wb, themes, styles) {
17927
17928
  if(!opts.cellStyles) break;
17928
17929
  while(val.e >= val.s) {
17929
17930
  colinfo[val.e--] = { width: val.w/256, hidden: !!(val.flags & 0x01), level: val.level };
17930
- if(!seencol) { seencol = true; find_mdw_colw(val.w/256); }
17931
+ if(!seencol) { seencol = true; MDW = DEF_MDW; }
17931
17932
  process_col(colinfo[val.e+1]);
17932
17933
  }
17933
17934
  break;
@@ -21467,7 +21468,7 @@ wb.opts.Date1904 = Workbook.WBProps.date1904 = val; break;
21467
21468
  while(val.e >= val.s) {
21468
21469
  colinfo[val.e--] = { width: val.w/256, level: (val.level || 0), hidden: !!(val.flags & 1) };
21469
21470
  if(val.ixfe != null && XFs[val.ixfe]) colinfo[val.e+1].s = resolve_xls_style(XFs[val.ixfe], val.ixfe);
21470
- if(!seencol) { seencol = true; find_mdw_colw(val.w/256); }
21471
+ if(!seencol) { seencol = true; MDW = DEF_MDW; }
21471
21472
  process_col(colinfo[val.e+1]);
21472
21473
  }
21473
21474
  } break;
@@ -26111,7 +26112,8 @@ var numbers_lut_new = function() {
26111
26112
  function numbers_format_cell(cell, t, flags, ofmt, nfmt) {
26112
26113
  var _a, _b, _c, _d;
26113
26114
  var ctype = t & 255, ver = t >> 8;
26114
- var fmt = ver >= 5 ? nfmt : ofmt;
26115
+ /* Missing legacy/new format tables mean the default format. */
26116
+ var fmt = (ver >= 5 ? nfmt : ofmt) || [];
26115
26117
  dur:
26116
26118
  if (flags & (ver > 4 ? 8 : 4) && cell.t == "n" && ctype == 7) {
26117
26119
  var dstyle = ((_a = fmt[7]) == null ? void 0 : _a[0]) ? varint_to_i32(fmt[7][0].data) : -1;
@@ -28026,6 +28028,7 @@ function drawing_mime(path) {
28026
28028
  case "bmp": return "image/bmp";
28027
28029
  case "svg": return "image/svg+xml";
28028
28030
  case "jpg": case "jpeg": return "image/jpeg";
28031
+ case "tif": case "tiff": return "image/tiff";
28029
28032
  default: return "application/octet-stream";
28030
28033
  }
28031
28034
  }
@@ -28041,7 +28044,9 @@ function parse_sheet_drawing(sheet, type, zip, path, idx, opts, wb) {
28041
28044
  if(!img || !img.target) return;
28042
28045
  var ipath = resolve_path(img.target, dfile);
28043
28046
  var ibin = getzipbin(zip, ipath, true);
28044
- if(ibin) img.dataURI = "data:" + drawing_mime(ipath) + ";base64," + Base64_encode_arr(ibin);
28047
+ var contentType = drawing_mime(ipath);
28048
+ if(ibin) img.dataURI = "data:" + contentType + ";base64," + Base64_encode_arr(ibin);
28049
+ img.contentType = contentType;
28045
28050
  img.path = ipath;
28046
28051
  });
28047
28052
  if(opts.charts && draw.charts && draw.charts.length) {
package/xlsx.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  /*exported XLSX */
4
4
  /*global process:false, Buffer:false, ArrayBuffer:false, DataView:false, Deno:false */
5
5
  var XLSX = {};
6
- XLSX.version = '0.21.1';
6
+ XLSX.version = '0.21.2';
7
7
  var current_codepage = 1200, current_ansi = 1252;
8
8
  /*:: declare var cptable:any; */
9
9
  /*global cptable:true, window */
@@ -11196,7 +11196,7 @@ function resolve_style_obj_color(obj, themes) {
11196
11196
 
11197
11197
  /* 18.3.1.13 width calculations */
11198
11198
  /* [MS-OI29500] 2.1.595 Column Width & Formatting */
11199
- var DEF_MDW = 6, MAX_MDW = 15, MIN_MDW = 1, MDW = DEF_MDW;
11199
+ var DEF_MDW = 7, MAX_MDW = 15, MIN_MDW = 1, MDW = DEF_MDW;
11200
11200
  function width2px(width) { return Math.floor(( width + (Math.round(128/MDW))/256 )* MDW ); }
11201
11201
  function px2char(px) { return (Math.floor((px - 5)/MDW * 100 + 0.5))/100; }
11202
11202
  function char2width(chr) { return (Math.round((chr * MDW + 5)/MDW*256))/256; }
@@ -16846,7 +16846,8 @@ function parse_ws_xml_cols(columns, cols) {
16846
16846
  var colm=parseInt(coll.min, 10)-1, colM=parseInt(coll.max,10)-1;
16847
16847
  if(coll.outlineLevel) coll.level = (+coll.outlineLevel || 0);
16848
16848
  delete coll.min; delete coll.max; coll.width = +coll.width;
16849
- if(!seencol && coll.width) { seencol = true; find_mdw_colw(coll.width); }
16849
+ /* OOXML widths share the workbook Normal-font MDW; do not infer a different scale per sheet. */
16850
+ if(!seencol && coll.width) { seencol = true; MDW = DEF_MDW; }
16850
16851
  process_col(coll);
16851
16852
  while(colm <= colM) columns[colm++] = dup(coll);
16852
16853
  }
@@ -18017,7 +18018,7 @@ function parse_ws_bin(data, _opts, idx, rels, wb/*:WBWBProps*/, themes, styles)/
18017
18018
  if(!opts.cellStyles) break;
18018
18019
  while(val.e >= val.s) {
18019
18020
  colinfo[val.e--] = { width: val.w/256, hidden: !!(val.flags & 0x01), level: val.level };
18020
- if(!seencol) { seencol = true; find_mdw_colw(val.w/256); }
18021
+ if(!seencol) { seencol = true; MDW = DEF_MDW; }
18021
18022
  process_col(colinfo[val.e+1]);
18022
18023
  }
18023
18024
  break;
@@ -21570,7 +21571,7 @@ function parse_workbook(blob, options/*:ParseOpts*/)/*:Workbook*/ {
21570
21571
  while(val.e >= val.s) {
21571
21572
  colinfo[val.e--] = { width: val.w/256, level: (val.level || 0), hidden: !!(val.flags & 1) };
21572
21573
  if(val.ixfe != null && XFs[val.ixfe]) colinfo[val.e+1].s = resolve_xls_style(XFs[val.ixfe], val.ixfe);
21573
- if(!seencol) { seencol = true; find_mdw_colw(val.w/256); }
21574
+ if(!seencol) { seencol = true; MDW = DEF_MDW; }
21574
21575
  process_col(colinfo[val.e+1]);
21575
21576
  }
21576
21577
  } break;
@@ -26216,7 +26217,8 @@ var numbers_lut_new = function() {
26216
26217
  function numbers_format_cell(cell, t, flags, ofmt, nfmt) {
26217
26218
  var _a, _b, _c, _d;
26218
26219
  var ctype = t & 255, ver = t >> 8;
26219
- var fmt = ver >= 5 ? nfmt : ofmt;
26220
+ /* Missing legacy/new format tables mean the default format. */
26221
+ var fmt = (ver >= 5 ? nfmt : ofmt) || [];
26220
26222
  dur:
26221
26223
  if (flags & (ver > 4 ? 8 : 4) && cell.t == "n" && ctype == 7) {
26222
26224
  var dstyle = ((_a = fmt[7]) == null ? void 0 : _a[0]) ? varint_to_i32(fmt[7][0].data) : -1;
@@ -28131,6 +28133,7 @@ function drawing_mime(path) {
28131
28133
  case "bmp": return "image/bmp";
28132
28134
  case "svg": return "image/svg+xml";
28133
28135
  case "jpg": case "jpeg": return "image/jpeg";
28136
+ case "tif": case "tiff": return "image/tiff";
28134
28137
  default: return "application/octet-stream";
28135
28138
  }
28136
28139
  }
@@ -28146,7 +28149,9 @@ function parse_sheet_drawing(sheet, type, zip, path, idx, opts, wb) {
28146
28149
  if(!img || !img.target) return;
28147
28150
  var ipath = resolve_path(img.target, dfile);
28148
28151
  var ibin = getzipbin(zip, ipath, true);
28149
- if(ibin) img.dataURI = "data:" + drawing_mime(ipath) + ";base64," + Base64_encode_arr(ibin);
28152
+ var contentType = drawing_mime(ipath);
28153
+ if(ibin) img.dataURI = "data:" + contentType + ";base64," + Base64_encode_arr(ibin);
28154
+ img.contentType = contentType;
28150
28155
  img.path = ipath;
28151
28156
  });
28152
28157
  if(opts.charts && draw.charts && draw.charts.length) {