@office-open/xlsx 0.10.1 → 0.10.3

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.
@@ -204,13 +204,13 @@ function parseRPr(el) {
204
204
  result.size = attrNum(child, "val");
205
205
  break;
206
206
  case "u":
207
- result.underline = attr(child, "val") ?? true;
207
+ result.underline = attr(child, "val") ?? "single";
208
208
  break;
209
209
  case "vertAlign":
210
- result.vertAlign = attr(child, "val") ?? void 0;
210
+ result.vertAlign = attr(child, "val");
211
211
  break;
212
212
  case "scheme":
213
- result.scheme = attr(child, "val") ?? void 0;
213
+ result.scheme = attr(child, "val");
214
214
  break;
215
215
  }
216
216
  return result;
@@ -300,7 +300,8 @@ const worksheetDesc = {
300
300
  if (attr(svEl, "showOutlineSymbols") === "0") sv.showOutlineSymbols = false;
301
301
  if (attr(svEl, "defaultGridColor") === "0") sv.defaultGridColor = false;
302
302
  if (attr(svEl, "showWhiteSpace") === "0") sv.showWhiteSpace = false;
303
- if (attr(svEl, "view")) sv.view = attr(svEl, "view");
303
+ const viewVal = attr(svEl, "view");
304
+ if (viewVal) sv.view = viewVal;
304
305
  const colorId = attrNum(svEl, "colorId");
305
306
  if (colorId !== void 0) sv.colorId = colorId;
306
307
  const zsn = attrNum(svEl, "zoomScaleNormal");
@@ -344,9 +345,10 @@ const worksheetDesc = {
344
345
  const columns = [];
345
346
  for (const colEl of colsEl.elements ?? []) {
346
347
  if (colEl.name !== "col") continue;
347
- const col = {};
348
- col.min = attrNum(colEl, "min") ?? 0;
349
- col.max = attrNum(colEl, "max") ?? 0;
348
+ const col = {
349
+ min: attrNum(colEl, "min") ?? 0,
350
+ max: attrNum(colEl, "max") ?? 0
351
+ };
350
352
  const w = attrNum(colEl, "width");
351
353
  if (w !== void 0) col.width = w;
352
354
  if (attr(colEl, "hidden") === "1") col.hidden = true;
@@ -391,16 +393,18 @@ const worksheetDesc = {
391
393
  const ranges = [];
392
394
  for (const rEl of prEl.elements ?? []) {
393
395
  if (rEl.name !== "protectedRange") continue;
394
- const r = {};
395
- r.sqref = attr(rEl, "sqref") ?? "";
396
- r.name = attr(rEl, "name") ?? "";
396
+ const r = {
397
+ sqref: attr(rEl, "sqref") ?? "",
398
+ name: attr(rEl, "name") ?? ""
399
+ };
397
400
  if (attr(rEl, "password")) r.password = attr(rEl, "password");
398
401
  if (attr(rEl, "algorithmName")) r.algorithmName = attr(rEl, "algorithmName");
399
402
  if (attr(rEl, "hashValue")) r.hashValue = attr(rEl, "hashValue");
400
403
  if (attr(rEl, "saltValue")) r.saltValue = attr(rEl, "saltValue");
401
- if (attrNum(rEl, "spinCount") !== void 0) r.spinCount = attrNum(rEl, "spinCount");
404
+ const spinCount = attrNum(rEl, "spinCount");
405
+ if (spinCount !== void 0) r.spinCount = spinCount;
402
406
  const sdEl = findChild(rEl, "securityDescriptor");
403
- if (sdEl) r.securityDescriptor = textOf(sdEl);
407
+ if (sdEl) r.securityDescriptor = textOf(sdEl) ?? void 0;
404
408
  ranges.push(r);
405
409
  }
406
410
  if (ranges.length > 0) result.protectedRanges = ranges;
@@ -432,14 +436,17 @@ const worksheetDesc = {
432
436
  const rules = [];
433
437
  for (const ruleEl of cfEl.elements ?? []) {
434
438
  if (ruleEl.name !== "cfRule") continue;
435
- const rule = {};
436
- rule.type = attr(ruleEl, "type");
437
- rule.priority = attrNum(ruleEl, "priority") ?? 1;
438
- if (attr(ruleEl, "operator")) rule.operator = attr(ruleEl, "operator");
439
+ const rule = {
440
+ type: attr(ruleEl, "type"),
441
+ priority: attrNum(ruleEl, "priority") ?? 1
442
+ };
443
+ const opVal = attr(ruleEl, "operator");
444
+ if (opVal) rule.operator = opVal;
439
445
  const dxfId = attrNum(ruleEl, "dxfId");
440
446
  if (dxfId !== void 0) rule.dxfId = dxfId;
441
447
  if (attr(ruleEl, "stopIfTrue") === "1") rule.stopIfTrue = true;
442
- if (attr(ruleEl, "timePeriod")) rule.timePeriod = attr(ruleEl, "timePeriod");
448
+ const tpVal = attr(ruleEl, "timePeriod");
449
+ if (tpVal) rule.timePeriod = tpVal;
443
450
  const rank = attrNum(ruleEl, "rank");
444
451
  if (rank !== void 0) rule.rank = rank;
445
452
  if (attr(ruleEl, "equalAverage") === "1") rule.equalAverage = true;
@@ -480,7 +487,8 @@ const worksheetDesc = {
480
487
  const cfvo = [];
481
488
  for (const child of isEl.elements ?? []) if (child.name === "cfvo") cfvo.push(parseCfvo(child));
482
489
  const iconSet = { cfvo };
483
- if (attr(isEl, "iconSet")) iconSet.iconSet = attr(isEl, "iconSet");
490
+ const isVal = attr(isEl, "iconSet");
491
+ if (isVal) iconSet.iconSet = isVal;
484
492
  if (attr(isEl, "showValue") === "0") iconSet.showValue = false;
485
493
  if (attr(isEl, "percent") === "0") iconSet.percent = false;
486
494
  if (attr(isEl, "reverse") === "1") iconSet.reverse = true;
@@ -503,10 +511,11 @@ const worksheetDesc = {
503
511
  const dvs = [];
504
512
  for (const dEl of dvEl.elements ?? []) {
505
513
  if (dEl.name !== "dataValidation") continue;
506
- const dv = {};
507
- dv.sqref = attr(dEl, "sqref") ?? "";
508
- if (attr(dEl, "type")) dv.type = attr(dEl, "type");
509
- if (attr(dEl, "operator")) dv.operator = attr(dEl, "operator");
514
+ const dv = { sqref: attr(dEl, "sqref") ?? "" };
515
+ const typeVal = attr(dEl, "type");
516
+ if (typeVal) dv.type = typeVal;
517
+ const opVal = attr(dEl, "operator");
518
+ if (opVal) dv.operator = opVal;
510
519
  if (attr(dEl, "allowBlank") === "1") dv.allowBlank = true;
511
520
  if (attr(dEl, "showErrorMessage") === "1") dv.showErrorMessage = true;
512
521
  if (attr(dEl, "showInputMessage") === "1") dv.showInputMessage = true;
@@ -514,8 +523,10 @@ const worksheetDesc = {
514
523
  if (attr(dEl, "error")) dv.error = attr(dEl, "error");
515
524
  if (attr(dEl, "promptTitle")) dv.promptTitle = attr(dEl, "promptTitle");
516
525
  if (attr(dEl, "prompt")) dv.prompt = attr(dEl, "prompt");
517
- if (attr(dEl, "errorStyle")) dv.errorStyle = attr(dEl, "errorStyle");
518
- if (attr(dEl, "imeMode")) dv.imeMode = attr(dEl, "imeMode");
526
+ const esVal = attr(dEl, "errorStyle");
527
+ if (esVal) dv.errorStyle = esVal;
528
+ const imVal = attr(dEl, "imeMode");
529
+ if (imVal) dv.imeMode = imVal;
519
530
  if (attr(dEl, "showDropDown") === "1") dv.showDropDown = true;
520
531
  const f1El = findChild(dEl, "formula1");
521
532
  if (f1El) dv.formula1 = textOf(f1El);
@@ -530,17 +541,18 @@ const worksheetDesc = {
530
541
  const hyperlinks = [];
531
542
  for (const hEl of hlEl.elements ?? []) {
532
543
  if (hEl.name !== "hyperlink") continue;
533
- const hl = {};
534
- hl.cell = attr(hEl, "ref") ?? "";
535
544
  const rId = hEl.attributes?.["r:id"];
536
545
  const location = attr(hEl, "location");
537
- if (rId) hl.target = {
546
+ const target = rId ? {
538
547
  type: "external",
539
548
  url: rId
540
- };
541
- else if (location) hl.target = {
549
+ } : {
542
550
  type: "internal",
543
- location
551
+ location: location ?? ""
552
+ };
553
+ const hl = {
554
+ cell: attr(hEl, "ref") ?? "",
555
+ target
544
556
  };
545
557
  if (attr(hEl, "tooltip")) hl.tooltip = attr(hEl, "tooltip");
546
558
  if (attr(hEl, "display")) hl.display = attr(hEl, "display");
@@ -567,14 +579,16 @@ const worksheetDesc = {
567
579
  if (ph !== void 0) ps.paperHeight = ph;
568
580
  const pw = attrMeasure(psEl, "paperWidth");
569
581
  if (pw !== void 0) ps.paperWidth = pw;
570
- if (attr(psEl, "orientation")) ps.orientation = attr(psEl, "orientation");
582
+ const orientVal = attr(psEl, "orientation");
583
+ if (orientVal) ps.orientation = orientVal;
571
584
  const sc = attrNum(psEl, "scale");
572
585
  if (sc !== void 0) ps.scale = sc;
573
586
  const ftw = attrNum(psEl, "fitToWidth");
574
587
  if (ftw !== void 0) ps.fitToWidth = ftw;
575
588
  const fth = attrNum(psEl, "fitToHeight");
576
589
  if (fth !== void 0) ps.fitToHeight = fth;
577
- if (attr(psEl, "pageOrder")) ps.pageOrder = attr(psEl, "pageOrder");
590
+ const pageOrderVal = attr(psEl, "pageOrder");
591
+ if (pageOrderVal) ps.pageOrder = pageOrderVal;
578
592
  if (attr(psEl, "useFirstPageNumber") === "1") ps.useFirstPageNumber = true;
579
593
  const fpn = attrNum(psEl, "firstPageNumber");
580
594
  if (fpn !== void 0) ps.firstPageNumber = fpn;
@@ -607,8 +621,7 @@ const worksheetDesc = {
607
621
  const errors = [];
608
622
  for (const eEl of ieEl.elements ?? []) {
609
623
  if (eEl.name !== "ignoredError") continue;
610
- const ie = {};
611
- ie.sqref = attr(eEl, "sqref") ?? "";
624
+ const ie = { sqref: attr(eEl, "sqref") ?? "" };
612
625
  if (attr(eEl, "evalError") === "1") ie.evalError = true;
613
626
  if (attr(eEl, "twoDigitTextYear") === "1") ie.twoDigitTextYear = true;
614
627
  if (attr(eEl, "numberStoredAsText") === "1") ie.numberStoredAsText = true;
@@ -624,10 +637,11 @@ const worksheetDesc = {
624
637
  }
625
638
  const ppEl = findChild(el, "phoneticPr");
626
639
  if (ppEl) {
627
- const pp = {};
628
- pp.fontId = attrNum(ppEl, "fontId") ?? 0;
629
- if (attr(ppEl, "type")) pp.type = attr(ppEl, "type");
630
- if (attr(ppEl, "alignment")) pp.alignment = attr(ppEl, "alignment");
640
+ const pp = { fontId: attrNum(ppEl, "fontId") ?? 0 };
641
+ const ppType = attr(ppEl, "type");
642
+ if (ppType) pp.type = ppType;
643
+ const ppAlign = attr(ppEl, "alignment");
644
+ if (ppAlign) pp.alignment = ppAlign;
631
645
  result.phoneticPr = pp;
632
646
  }
633
647
  const scEl = findChild(el, "sheetCalcPr");
@@ -1499,8 +1513,7 @@ function dateToSerialNumber(date) {
1499
1513
  return (date.getTime() - epoch.getTime()) / 864e5;
1500
1514
  }
1501
1515
  function parseCfvo(el) {
1502
- const result = {};
1503
- result.type = attr(el, "type") ?? "num";
1516
+ const result = { type: attr(el, "type") ?? "num" };
1504
1517
  const val = attr(el, "val");
1505
1518
  if (val !== void 0) result.val = isNaN(Number(val)) ? val : Number(val);
1506
1519
  if (attr(el, "gte") === "0") result.gte = false;
@@ -1724,4 +1737,4 @@ function parseRst(textEl) {
1724
1737
  //#endregion
1725
1738
  export { SharedStrings as a, worksheetDesc as i, vmlNotesDesc as n, sharedStringsDesc as o, stringifyWorksheet as r, commentsDesc as t };
1726
1739
 
1727
- //# sourceMappingURL=comments-CIu-wLTT.mjs.map
1740
+ //# sourceMappingURL=comments-CQ5dlj-4.mjs.map