@niicojs/excel 0.2.5 → 0.2.7
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/dist/index.cjs +190 -16
- package/dist/index.d.cts +30 -7
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +30 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +190 -16
- package/package.json +1 -1
- package/src/pivot-table.ts +86 -23
- package/src/styles.ts +64 -4
- package/src/types.ts +4 -2
- package/src/workbook.ts +4 -0
package/dist/index.d.ts
CHANGED
|
@@ -89,10 +89,12 @@ type AggregationType = 'sum' | 'count' | 'average' | 'min' | 'max';
|
|
|
89
89
|
interface PivotValueConfig {
|
|
90
90
|
/** Source field name (column header) */
|
|
91
91
|
field: string;
|
|
92
|
-
/** Aggregation function */
|
|
93
|
-
aggregation
|
|
92
|
+
/** Aggregation function (default: 'sum') */
|
|
93
|
+
aggregation?: AggregationType;
|
|
94
94
|
/** Display name (e.g., "Sum of Sales") */
|
|
95
95
|
name?: string;
|
|
96
|
+
/** Number format (e.g., '$#,##0.00', '0.00%') */
|
|
97
|
+
numberFormat?: string;
|
|
96
98
|
}
|
|
97
99
|
/**
|
|
98
100
|
* Configuration for creating a pivot table
|
|
@@ -521,6 +523,12 @@ declare class Styles {
|
|
|
521
523
|
private _findOrCreateFill;
|
|
522
524
|
private _findOrCreateBorder;
|
|
523
525
|
private _findOrCreateNumFmt;
|
|
526
|
+
/**
|
|
527
|
+
* Get or create a number format ID for the given format string.
|
|
528
|
+
* Returns built-in IDs (0-163) for standard formats, or creates custom IDs (164+).
|
|
529
|
+
* @param format - The number format string (e.g., '0.00', '#,##0', '$#,##0.00')
|
|
530
|
+
*/
|
|
531
|
+
getOrCreateNumFmtId(format: string): number;
|
|
524
532
|
/**
|
|
525
533
|
* Check if styles have been modified
|
|
526
534
|
*/
|
|
@@ -620,6 +628,7 @@ declare class PivotTable {
|
|
|
620
628
|
private _valueFields;
|
|
621
629
|
private _filterFields;
|
|
622
630
|
private _pivotTableIndex;
|
|
631
|
+
private _styles;
|
|
623
632
|
constructor(name: string, cache: PivotCache, targetSheet: string, targetCell: string, targetRow: number, targetCol: number, pivotTableIndex: number);
|
|
624
633
|
/**
|
|
625
634
|
* Get the pivot table name
|
|
@@ -641,6 +650,11 @@ declare class PivotTable {
|
|
|
641
650
|
* Get the pivot table index (for file naming)
|
|
642
651
|
*/
|
|
643
652
|
get index(): number;
|
|
653
|
+
/**
|
|
654
|
+
* Set the styles reference for number format resolution
|
|
655
|
+
* @internal
|
|
656
|
+
*/
|
|
657
|
+
setStyles(styles: Styles): this;
|
|
644
658
|
/**
|
|
645
659
|
* Add a field to the row area
|
|
646
660
|
* @param fieldName - Name of the source field (column header)
|
|
@@ -652,12 +666,21 @@ declare class PivotTable {
|
|
|
652
666
|
*/
|
|
653
667
|
addColumnField(fieldName: string): this;
|
|
654
668
|
/**
|
|
655
|
-
* Add a field to the values area with aggregation
|
|
656
|
-
*
|
|
657
|
-
*
|
|
658
|
-
*
|
|
669
|
+
* Add a field to the values area with aggregation.
|
|
670
|
+
*
|
|
671
|
+
* Supports two call signatures:
|
|
672
|
+
* - Positional: `addValueField(fieldName, aggregation?, displayName?, numberFormat?)`
|
|
673
|
+
* - Object: `addValueField({ field, aggregation?, name?, numberFormat? })`
|
|
674
|
+
*
|
|
675
|
+
* @example
|
|
676
|
+
* // Positional arguments
|
|
677
|
+
* pivot.addValueField('Sales', 'sum', 'Total Sales', '$#,##0.00');
|
|
678
|
+
*
|
|
679
|
+
* // Object form
|
|
680
|
+
* pivot.addValueField({ field: 'Sales', aggregation: 'sum', name: 'Total Sales', numberFormat: '$#,##0.00' });
|
|
659
681
|
*/
|
|
660
|
-
addValueField(
|
|
682
|
+
addValueField(config: PivotValueConfig): this;
|
|
683
|
+
addValueField(fieldName: string, aggregation?: AggregationType, displayName?: string, numberFormat?: string): this;
|
|
661
684
|
/**
|
|
662
685
|
* Add a field to the filter (page) area
|
|
663
686
|
* @param fieldName - Name of the source field (column header)
|