style-xlsx-m 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/xlsx.js +53 -145
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "style-xlsx-m",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "author": "mor8t",
5
5
  "description": "SheetJS and with Style! Get and Export Excel with basic styling options using JavaScript. But only get in xlsx and xlsm format.",
6
6
  "keywords": [
package/xlsx.js CHANGED
@@ -10151,35 +10151,28 @@ function parse_borders(t, styles, themes, opts) {
10151
10151
  /* 18.8.? color CT_Color */case '<color':
10152
10152
  if(!color) color = {};
10153
10153
  if(y.auto) color.auto = parsexmlbool(y.auto);
10154
-
10155
- if(y.rgb){ color.rgb = y.rgb.slice(-6);}
10156
- else if(y.indexed) {
10157
- color.index = parseInt(y.indexed, 10);
10158
- var icv = XLSIcv[color.index];
10159
- if(color.index == 81) icv = XLSIcv[1];
10160
- if(!icv) icv = XLSIcv[1]; //throw new Error(x); // note: 206 is valid
10161
- color.rgb = icv[0].toString(16) + icv[1].toString(16) + icv[2].toString(16);
10162
- } else if(y.theme) {
10163
- color = {}
10164
- color.theme = parseInt(y.theme, 10);
10165
- if(y.tint) color.tint = parseFloat(y.tint);
10166
- if(y.theme && themes.themeElements && themes.themeElements.clrScheme) {
10167
- color.rgb = rgb_tint(themes.themeElements.clrScheme[color.theme].rgb, color.tint || 0);
10168
- }
10169
- }
10170
- // console.log(color)
10171
- if(color.index && color.rgb && !color.theme){
10172
- if(color.index == 64){
10173
- color = {rgb:'000'}
10174
- }else{
10175
- color = {rgb:color.rgb}
10176
- }
10177
- }else if(!color.index && color.rgb && color.theme){
10178
- color = {rgb:color.rgb}
10179
- }else{
10180
- color = {index:color.index}
10154
+ if(y.rgb){ color.rgb = y.rgb.slice(-6);}
10155
+ else if(y.indexed) {
10156
+ color.index = parseInt(y.indexed, 10);
10157
+ var icv = XLSIcv[color.index];
10158
+ if(color.index == 81) icv = XLSIcv[1];
10159
+ if(!icv) icv = XLSIcv[1]; //throw new Error(x); // note: 206 is valid
10160
+ color.rgb = icv[0].toString(16) + icv[1].toString(16) + icv[2].toString(16);
10161
+ } else if(y.theme) {
10162
+ color = {}
10163
+ color.theme = parseInt(y.theme, 10);
10164
+ if(y.tint) color.tint = parseFloat(y.tint);
10165
+ if(y.theme && themes.themeElements && themes.themeElements.clrScheme) {
10166
+ color.rgb = rgb_tint(themes.themeElements.clrScheme[color.theme].rgb, color.tint || 0);
10181
10167
  }
10182
- break;
10168
+ }
10169
+ if(color.index && color.rgb && !color.theme){
10170
+ if(color.index == 64) color = {rgb:'000'}
10171
+ else color = {rgb:color.rgb}
10172
+ }
10173
+ else if(!color.index && color.rgb && color.theme) color = {rgb:color.rgb};
10174
+ else color = {index:color.index};
10175
+ break;
10183
10176
  case '<color/>': case '</color>': break;
10184
10177
 
10185
10178
  /* 18.2.10 extLst CT_ExtensionList ? */
@@ -14532,18 +14525,11 @@ function safe_format(p, fmtid, fillid, opts, themes, styles, fontid, borderid,cf
14532
14525
  } catch(e) { if(opts.WTF) throw e; }
14533
14526
  if(!opts.cellStyles) return;
14534
14527
  // if(fillid != null) try {
14535
- // // p.s = {
14536
- // // ...styles.Fills[fillid],
14537
- // // };
14538
- // // console.log('p style',p)
14539
- // // const styles = {}
14540
- // // console.log(styles.Fills[fillid])
14528
+ // // p.s = {...styles.Fills[fillid]};
14541
14529
  // const pss = {...styles.Fills[fillid]}
14542
14530
  // if (pss.fgColor && pss.fgColor.theme && !pss.fgColor.rgb) {
14543
14531
  // p.s.fgColor.rgb = rgb_tint(themes.themeElements.clrScheme[pss.fgColor.theme].rgb, pss.fgColor.tint || 0);
14544
14532
  // if(opts.WTF) p.s.fgColor.raw_rgb = themes.themeElements.clrScheme[pss.fgColor.theme].rgb;
14545
- // const bg = { rgb: pss.fgColor.rgb };
14546
- // p.s.fill = {...pss.fill, fgColor: bg, bgColor: bg };
14547
14533
  // }
14548
14534
  // if (pss.bgColor && (pss.bgColor.theme || pss.bgColor.theme == 0)) {
14549
14535
  // p.s.Fills[fillid].bgColor.rgb = rgb_tint(themes.themeElements.clrScheme[pss.bgColor.theme].rgb, pss.bgColor.tint || 0);
@@ -14552,74 +14538,28 @@ function safe_format(p, fmtid, fillid, opts, themes, styles, fontid, borderid,cf
14552
14538
  // if(pss.patternType){
14553
14539
  // if(pss.fgColor.rgb){
14554
14540
  // const bg = { rgb: pss.fgColor.rgb };
14555
- // p.s.fill = {
14556
- // fgColor: bg,
14557
- // bgColor: bg ,
14541
+ // p.s.fill = {fgColor: bg, bgColor: bg ,
14558
14542
  // patternType: pss.patternType == 'solid' ? 'solid' : 'none',
14559
14543
  // }
14560
14544
  // }else {
14561
- // p.s.fill = {
14562
- // patternType: pss.patternType == 'solid' ? 'solid' : 'none',
14563
- // }
14545
+ // p.s.fill = {patternType: pss.patternType == 'solid' ? 'solid' : 'none',}
14564
14546
  // }
14565
14547
  // }
14566
14548
  // } catch(e) { if(opts.WTF && styles.Fills) throw e; }
14567
14549
  if(fontid != null){
14568
- p.s = {
14569
- ...p.s,
14570
- ...styles.Fonts[fontid],
14571
- }
14572
- if (p.s.sz) {
14573
- p.s.font = { ...p.s.font, sz: p.s.sz };
14574
- }
14575
- if (p.s.color) {
14576
- p.s.font = {
14577
- ...p.s.font,
14578
- color: p.s.color,
14579
- };
14580
- }
14581
- if (p.s.underline) {
14582
- p.s.font = {
14583
- ...p.s.font,
14584
- underline: p.s.underline ? true : false,
14585
- };
14586
- }
14587
- if (p.s.strike) {
14588
- p.s.font = {
14589
- ...p.s.font,
14590
- strike: p.s.strike ? true : false,
14591
- };
14592
- }
14593
- if (p.s.bold) {
14594
- p.s.font = {
14595
- ...p.s.font,
14596
- bold: p.s.bold ? true : false,
14597
- };
14598
- }
14599
- if (p.s.italic) {
14600
- p.s.font = {
14601
- ...p.s.font,
14602
- italic: p.s.italic ? true : false,
14603
- };
14604
- }
14605
- if (p.s.name) {
14606
- p.s.font = {
14607
- ...p.s.font,
14608
- name: p.s.name,
14609
- };
14610
- }
14611
- }
14612
- if(borderid != null){
14613
- p.s.border = styles.Borders[borderid]
14614
- }
14615
- if(cf.alignment){
14616
- p.s = {
14617
- ...p.s,
14618
- alignment:cf.alignment
14619
- }
14620
- }
14550
+ p.s = {...p.s,...styles.Fonts[fontid],}
14551
+ if (p.s.sz) p.s.font = { ...p.s.font, sz: p.s.sz };
14552
+ if (p.s.color) p.s.font = {...p.s.font, color: p.s.color,};
14553
+ if (p.s.underline) p.s.font = { ...p.s.font, underline: p.s.underline ? true : false,};
14554
+ if (p.s.strike) p.s.font = { ...p.s.font, strike: p.s.strike ? true : false, };
14555
+ if (p.s.bold) p.s.font = { ...p.s.font, bold: p.s.bold ? true : false, };
14556
+ if (p.s.italic) p.s.font = { ...p.s.font, italic: p.s.italic ? true : false, };
14557
+ if (p.s.name) p.s.font = { ...p.s.font, name: p.s.name, };
14558
+ }
14559
+ if(borderid != null) p.s.border = styles.Borders[borderid]
14560
+ if(cf.alignment) p.s = {...p.s, alignment:cf.alignment}
14621
14561
  if(p.s && p.t == 'z'){
14622
- p.t = 's'
14562
+ p.t = 's';
14623
14563
  // p.z = 'General'
14624
14564
  p.v = ' '
14625
14565
  p.w = ' '
@@ -14948,29 +14888,6 @@ var parse_ws_xml_data = (function() {
14948
14888
  var refregex = /ref=["']([^"']*)["']/;
14949
14889
  var match_v = matchtag("v"), match_f = matchtag("f");
14950
14890
 
14951
- //00000000000000000000000000000000000000000000000000000000000000000000000000000000
14952
- //00000000000000000000000000000000000000000000000000000000000000000000000000000000
14953
- //00000000000000000000000000000000000000000000000000000000000000000000000000000000
14954
- //00000000000000000000000000000000000000000000000000000000000000000000000000000000
14955
- //00000000000000000000000000000000000000000000000000000000000000000000000000000000
14956
- //00000000000000000000000000000000000000000000000000000000000000000000000000000000
14957
- //00000000000000000000000000000000000000000000000000000000000000000000000000000000
14958
- //00000000000000000000000000000000000000000000000000000000000000000000000000000000
14959
- //00000000000000000000000000000000000000000000000000000000000000000000000000000000
14960
- //00000000000000000000000000000000000000000000000000000000000000000000000000000000
14961
- //00000000000000000000000000000000000000000000000000000000000000000000000000000000
14962
- //00000000000000000000000000000000000000000000000000000000000000000000000000000000
14963
- //00000000000000000000000000000000000000000000000000000000000000000000000000000000
14964
- //00000000000000000000000000000000000000000000000000000000000000000000000000000000
14965
- //00000000000000000000000000000000000000000000000000000000000000000000000000000000
14966
- //00000000000000000000000000000000000000000000000000000000000000000000000000000000
14967
- //00000000000000000000000000000000000000000000000000000000000000000000000000000000
14968
- //00000000000000000000000000000000000000000000000000000000000000000000000000000000
14969
- //00000000000000000000000000000000000000000000000000000000000000000000000000000000
14970
- //00000000000000000000000000000000000000000000000000000000000000000000000000000000
14971
- //00000000000000000000000000000000000000000000000000000000000000000000000000000000
14972
- //00000000000000000000000000000000000000000000000000000000000000000000000000000000
14973
- //00000000000000000000000000000000000000000000000000000000000000000000000000000000
14974
14891
  return function parse_ws_xml_data(sdata, s, opts, guess, themes, styles) {
14975
14892
  // console.log('1111111111111111111111111111111111111111111111111111111111111111111111111111111111111')
14976
14893
  var ri = 0, x = "", cells = [], cref = [], idx=0, i=0, cc=0, d="", p;
@@ -23451,30 +23368,6 @@ function parse_zip(zip, opts) {
23451
23368
  Themes: themes,
23452
23369
  SSF: dup(table_fmt)
23453
23370
  });
23454
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23455
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23456
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23457
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23458
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23459
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23460
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23461
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23462
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23463
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23464
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23465
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23466
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23467
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23468
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23469
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23470
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23471
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23472
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23473
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23474
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23475
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23476
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23477
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23478
23371
  if(opts && opts.bookFiles) {
23479
23372
  if(zip.files) {
23480
23373
  out.keys = entries;
@@ -24438,7 +24331,8 @@ function book_new() {
24438
24331
  }
24439
24332
 
24440
24333
  /* add a worksheet to the end of a given workbook */
24441
- function book_append_sheet(wb, ws, name, roll) {
24334
+ function book_append_sheet(wb, ws, name, roll, nameSheet) {
24335
+ console.log('book_append_sheet')
24442
24336
  var i = 1;
24443
24337
  if(!name) for(; i <= 0xFFFF; ++i, name = undefined) if(wb.SheetNames.indexOf(name = "Sheet" + i) == -1) break;
24444
24338
  if(!name || wb.SheetNames.length >= 0xFFFF) throw new Error("Too many worksheets");
@@ -24452,7 +24346,21 @@ function book_append_sheet(wb, ws, name, roll) {
24452
24346
  if(wb.SheetNames.indexOf(name) >= 0) throw new Error("Worksheet with name |" + name + "| already exists!");
24453
24347
 
24454
24348
  wb.SheetNames.push(name);
24455
- wb.Sheets[name] = ws;
24349
+ if(nameSheet && typeof nameSheet == 'string'){
24350
+ const wsws = wb.Sheets[nameSheet]
24351
+ const nws = {...ws}
24352
+ Object.keys(ws).map((el) => {
24353
+ if(typeof +el.split('')[el.length-1] == 'number'){
24354
+ nws[el].s = {...wsws[el].s}
24355
+ }
24356
+ })
24357
+ console.log(nws['A1'],wsws['A1'],'-----------------------------/////////------------------')
24358
+ wb.Sheets[nameSheet] = nws;
24359
+ }else{
24360
+ wb.Sheets[name] = ws;
24361
+ }
24362
+ // console.log(ws)
24363
+ // console.log('name',name,'name 2',Object.keys(wb.Sheets)[0])
24456
24364
  return name;
24457
24365
  }
24458
24366