juxscript 1.1.201 → 1.1.202
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabularDriver.d.ts","sourceRoot":"","sources":["TabularDriver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,WAAW,WAAW;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,YAAY;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC5D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,qBAAa,aAAa;IACtB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,GA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AG,OAAO,CAAC,IAAI,CAAC;IAYjC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAgB5B;;OAEG;IACG,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,SAAS,CAAC;IA0ExE;;;OAGG;IACG,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAmItG,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,UAAU;IAmClB,OAAO,CAAC,SAAS;IAYjB,KAAK,IAAI,IAAI;CAMhB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,aAAa,CAEhF"}
|
|
@@ -520,74 +520,66 @@ export class TabularDriver {
|
|
|
520
520
|
continue;
|
|
521
521
|
}
|
|
522
522
|
const range = XLSX.utils.decode_range(ref);
|
|
523
|
-
const
|
|
524
|
-
const
|
|
525
|
-
|
|
523
|
+
const startRow = range.s.r; // first row index
|
|
524
|
+
const endRow = range.e.r; // last row index
|
|
525
|
+
const startCol = range.s.c; // first col index
|
|
526
|
+
const endCol = range.e.c; // last col index
|
|
527
|
+
const numCols = endCol - startCol + 1;
|
|
528
|
+
if (endRow < startRow) {
|
|
526
529
|
processedSheets++;
|
|
527
530
|
continue;
|
|
528
531
|
}
|
|
529
|
-
//
|
|
530
|
-
const
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
532
|
+
// Helper: read a single cell value from the worksheet
|
|
533
|
+
const getCellValue = (r, c) => {
|
|
534
|
+
const cellAddress = XLSX.utils.encode_cell({ r, c });
|
|
535
|
+
const cell = worksheet[cellAddress];
|
|
536
|
+
if (!cell)
|
|
537
|
+
return null;
|
|
538
|
+
// Use formatted value (v = raw, w = formatted text)
|
|
539
|
+
return cell.v !== undefined ? cell.v : null;
|
|
540
|
+
};
|
|
541
|
+
// Helper: read an entire row as an array
|
|
542
|
+
const readRow = (r) => {
|
|
543
|
+
const vals = [];
|
|
544
|
+
for (let c = startCol; c <= endCol; c++) {
|
|
545
|
+
vals.push(getCellValue(r, c));
|
|
546
|
+
}
|
|
547
|
+
return vals;
|
|
548
|
+
};
|
|
549
|
+
// The actual row in the sheet for the header
|
|
550
|
+
const headerSheetRow = startRow + headerRow;
|
|
551
|
+
if (headerSheetRow > endRow) {
|
|
552
|
+
console.warn(`[TabularDriver] headerRow ${headerRow} exceeds sheet range (max row: ${endRow - startRow})`);
|
|
543
553
|
processedSheets++;
|
|
544
554
|
continue;
|
|
545
555
|
}
|
|
546
|
-
//
|
|
547
|
-
const
|
|
548
|
-
//
|
|
549
|
-
|
|
550
|
-
for (let i = headerRow; i < Math.min(rawData.length, headerRow + 100); i++) {
|
|
551
|
-
if (rawData[i] && rawData[i].length > maxCols) {
|
|
552
|
-
maxCols = rawData[i].length;
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
// Build headers array with proper length
|
|
556
|
-
const headers = [];
|
|
557
|
-
for (let j = 0; j < maxCols; j++) {
|
|
558
|
-
const h = headerRowData[j];
|
|
556
|
+
// Read header row values directly from cells
|
|
557
|
+
const headerValues = readRow(headerSheetRow);
|
|
558
|
+
// Build headers array
|
|
559
|
+
const headers = headerValues.map((h, i) => {
|
|
559
560
|
if (h === null || h === undefined || String(h).trim() === '') {
|
|
560
|
-
|
|
561
|
-
}
|
|
562
|
-
else {
|
|
563
|
-
headers.push(String(h).trim());
|
|
561
|
+
return `__EMPTY${i > 0 ? '_' + i : ''}`;
|
|
564
562
|
}
|
|
565
|
-
|
|
563
|
+
return String(h).trim();
|
|
564
|
+
});
|
|
566
565
|
// Ensure we have at least one valid header
|
|
567
566
|
const validHeaders = headers.filter(h => !h.startsWith('__EMPTY'));
|
|
568
567
|
if (validHeaders.length === 0) {
|
|
569
|
-
console.warn(`[TabularDriver] No valid headers found at row ${headerRow}`);
|
|
568
|
+
console.warn(`[TabularDriver] No valid headers found at row ${headerRow} in sheet "${sheetName}"`);
|
|
570
569
|
processedSheets++;
|
|
571
570
|
continue;
|
|
572
571
|
}
|
|
573
|
-
// Build rows
|
|
572
|
+
// Build data rows: everything after the header row
|
|
574
573
|
const rows = [];
|
|
575
|
-
for (let
|
|
576
|
-
const rowData =
|
|
574
|
+
for (let r = headerSheetRow + 1; r <= endRow; r++) {
|
|
575
|
+
const rowData = readRow(r);
|
|
577
576
|
// Skip completely empty rows
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
}
|
|
581
|
-
// Skip rows where all cells are null/undefined/empty
|
|
582
|
-
const hasContent = rowData.some((cell) => cell !== null && cell !== undefined && String(cell).trim() !== '');
|
|
583
|
-
if (!hasContent) {
|
|
577
|
+
const hasContent = rowData.some(cell => cell !== null && cell !== undefined && String(cell).trim() !== '');
|
|
578
|
+
if (!hasContent)
|
|
584
579
|
continue;
|
|
585
|
-
}
|
|
586
580
|
const row = {};
|
|
587
581
|
for (let j = 0; j < headers.length; j++) {
|
|
588
|
-
|
|
589
|
-
const cellValue = j < rowData.length ? rowData[j] : null;
|
|
590
|
-
row[header] = cellValue;
|
|
582
|
+
row[headers[j]] = rowData[j] !== undefined ? rowData[j] : null;
|
|
591
583
|
}
|
|
592
584
|
rows.push(row);
|
|
593
585
|
}
|
|
@@ -646,87 +646,77 @@ export class TabularDriver {
|
|
|
646
646
|
}
|
|
647
647
|
|
|
648
648
|
const range = XLSX.utils.decode_range(ref);
|
|
649
|
-
const
|
|
650
|
-
const
|
|
649
|
+
const startRow = range.s.r; // first row index
|
|
650
|
+
const endRow = range.e.r; // last row index
|
|
651
|
+
const startCol = range.s.c; // first col index
|
|
652
|
+
const endCol = range.e.c; // last col index
|
|
653
|
+
const numCols = endCol - startCol + 1;
|
|
651
654
|
|
|
652
|
-
if (
|
|
655
|
+
if (endRow < startRow) {
|
|
653
656
|
processedSheets++;
|
|
654
657
|
continue;
|
|
655
658
|
}
|
|
656
659
|
|
|
657
|
-
//
|
|
658
|
-
const
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
660
|
+
// Helper: read a single cell value from the worksheet
|
|
661
|
+
const getCellValue = (r: number, c: number): any => {
|
|
662
|
+
const cellAddress = XLSX.utils.encode_cell({ r, c });
|
|
663
|
+
const cell = worksheet[cellAddress];
|
|
664
|
+
if (!cell) return null;
|
|
665
|
+
// Use formatted value (v = raw, w = formatted text)
|
|
666
|
+
return cell.v !== undefined ? cell.v : null;
|
|
667
|
+
};
|
|
664
668
|
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
+
// Helper: read an entire row as an array
|
|
670
|
+
const readRow = (r: number): any[] => {
|
|
671
|
+
const vals: any[] = [];
|
|
672
|
+
for (let c = startCol; c <= endCol; c++) {
|
|
673
|
+
vals.push(getCellValue(r, c));
|
|
674
|
+
}
|
|
675
|
+
return vals;
|
|
676
|
+
};
|
|
677
|
+
|
|
678
|
+
// The actual row in the sheet for the header
|
|
679
|
+
const headerSheetRow = startRow + headerRow;
|
|
669
680
|
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
console.warn(`[TabularDriver] headerRow ${headerRow} exceeds data length ${rawData.length}`);
|
|
681
|
+
if (headerSheetRow > endRow) {
|
|
682
|
+
console.warn(`[TabularDriver] headerRow ${headerRow} exceeds sheet range (max row: ${endRow - startRow})`);
|
|
673
683
|
processedSheets++;
|
|
674
684
|
continue;
|
|
675
685
|
}
|
|
676
686
|
|
|
677
|
-
//
|
|
678
|
-
const
|
|
687
|
+
// Read header row values directly from cells
|
|
688
|
+
const headerValues = readRow(headerSheetRow);
|
|
679
689
|
|
|
680
|
-
//
|
|
681
|
-
|
|
682
|
-
for (let i = headerRow; i < Math.min(rawData.length, headerRow + 100); i++) {
|
|
683
|
-
if (rawData[i] && rawData[i].length > maxCols) {
|
|
684
|
-
maxCols = rawData[i].length;
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
// Build headers array with proper length
|
|
689
|
-
const headers: string[] = [];
|
|
690
|
-
for (let j = 0; j < maxCols; j++) {
|
|
691
|
-
const h = headerRowData[j];
|
|
690
|
+
// Build headers array
|
|
691
|
+
const headers: string[] = headerValues.map((h: any, i: number) => {
|
|
692
692
|
if (h === null || h === undefined || String(h).trim() === '') {
|
|
693
|
-
|
|
694
|
-
} else {
|
|
695
|
-
headers.push(String(h).trim());
|
|
693
|
+
return `__EMPTY${i > 0 ? '_' + i : ''}`;
|
|
696
694
|
}
|
|
697
|
-
|
|
695
|
+
return String(h).trim();
|
|
696
|
+
});
|
|
698
697
|
|
|
699
698
|
// Ensure we have at least one valid header
|
|
700
699
|
const validHeaders = headers.filter(h => !h.startsWith('__EMPTY'));
|
|
701
700
|
if (validHeaders.length === 0) {
|
|
702
|
-
console.warn(`[TabularDriver] No valid headers found at row ${headerRow}`);
|
|
701
|
+
console.warn(`[TabularDriver] No valid headers found at row ${headerRow} in sheet "${sheetName}"`);
|
|
703
702
|
processedSheets++;
|
|
704
703
|
continue;
|
|
705
704
|
}
|
|
706
705
|
|
|
707
|
-
// Build rows
|
|
706
|
+
// Build data rows: everything after the header row
|
|
708
707
|
const rows: Record<string, any>[] = [];
|
|
709
|
-
for (let
|
|
710
|
-
const rowData =
|
|
708
|
+
for (let r = headerSheetRow + 1; r <= endRow; r++) {
|
|
709
|
+
const rowData = readRow(r);
|
|
711
710
|
|
|
712
711
|
// Skip completely empty rows
|
|
713
|
-
|
|
714
|
-
continue;
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
// Skip rows where all cells are null/undefined/empty
|
|
718
|
-
const hasContent = rowData.some((cell: any) =>
|
|
712
|
+
const hasContent = rowData.some(cell =>
|
|
719
713
|
cell !== null && cell !== undefined && String(cell).trim() !== ''
|
|
720
714
|
);
|
|
721
|
-
if (!hasContent)
|
|
722
|
-
continue;
|
|
723
|
-
}
|
|
715
|
+
if (!hasContent) continue;
|
|
724
716
|
|
|
725
717
|
const row: Record<string, any> = {};
|
|
726
718
|
for (let j = 0; j < headers.length; j++) {
|
|
727
|
-
|
|
728
|
-
const cellValue = j < rowData.length ? rowData[j] : null;
|
|
729
|
-
row[header] = cellValue;
|
|
719
|
+
row[headers[j]] = rowData[j] !== undefined ? rowData[j] : null;
|
|
730
720
|
}
|
|
731
721
|
rows.push(row);
|
|
732
722
|
}
|