@devmm/puredocs-excel 1.0.3 → 1.0.5
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/LICENSE +21 -0
- package/dist/index.cjs +474 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +142 -29
- package/dist/index.d.ts +142 -29
- package/dist/index.js +474 -38
- package/dist/index.js.map +1 -1
- package/package.json +55 -55
package/dist/index.d.cts
CHANGED
|
@@ -506,8 +506,20 @@ declare class Cell {
|
|
|
506
506
|
getValue(): CellValue;
|
|
507
507
|
/**
|
|
508
508
|
* Returns the display text of the cell value (always a string).
|
|
509
|
+
*
|
|
510
|
+
* Numbers are returned unformatted; use {@link getFormattedText} to apply the
|
|
511
|
+
* cell's number format.
|
|
509
512
|
*/
|
|
510
513
|
getText(): string;
|
|
514
|
+
/**
|
|
515
|
+
* Returns the display text with the cell's number format applied, e.g. a
|
|
516
|
+
* value of 4.5 under `$#,##0.00` renders as `$4.50`.
|
|
517
|
+
*
|
|
518
|
+
* Falls back to {@link getText} for non-numeric values and for format codes
|
|
519
|
+
* outside the supported subset (fractions, scientific notation, conditional
|
|
520
|
+
* sections) — so the result is never a misleading rendering.
|
|
521
|
+
*/
|
|
522
|
+
getFormattedText(): string;
|
|
511
523
|
/**
|
|
512
524
|
* Sets a formula. The leading '=' is optional.
|
|
513
525
|
* Clears any cached value.
|
|
@@ -612,6 +624,58 @@ declare function buildDrawingXml(anchorsXml: string): string;
|
|
|
612
624
|
/** Builds a generic `.rels` part from a list of `<Relationship .../>` strings. */
|
|
613
625
|
declare function buildRelsXml(relationships: readonly string[]): string;
|
|
614
626
|
|
|
627
|
+
/**
|
|
628
|
+
* Represents the contents of an unzipped xlsx file.
|
|
629
|
+
* Keys are file paths within the archive (e.g. "xl/workbook.xml").
|
|
630
|
+
* Values are raw UTF-8 bytes.
|
|
631
|
+
*/
|
|
632
|
+
type ZipEntries = Map<string, Uint8Array>;
|
|
633
|
+
/**
|
|
634
|
+
* Unzips an xlsx file buffer into a map of path → bytes.
|
|
635
|
+
*
|
|
636
|
+
* @param buffer - ArrayBuffer or Uint8Array of the xlsx file
|
|
637
|
+
* @returns Map of file paths to their raw bytes
|
|
638
|
+
*/
|
|
639
|
+
declare function unzipXlsx(buffer: ArrayBuffer | Uint8Array): ZipEntries;
|
|
640
|
+
/**
|
|
641
|
+
* Reads and decodes a UTF-8 text entry from a zip archive.
|
|
642
|
+
* Returns undefined if the entry does not exist.
|
|
643
|
+
*/
|
|
644
|
+
declare function readXmlEntry(entries: ZipEntries, path: string): string | undefined;
|
|
645
|
+
/**
|
|
646
|
+
* Reads and decodes a UTF-8 text entry, throwing if missing.
|
|
647
|
+
*/
|
|
648
|
+
declare function requireXmlEntry(entries: ZipEntries, path: string): string;
|
|
649
|
+
/**
|
|
650
|
+
* Returns all entry paths that match the given prefix.
|
|
651
|
+
* Useful for listing worksheets: prefix = "xl/worksheets/".
|
|
652
|
+
*/
|
|
653
|
+
declare function listEntries(entries: ZipEntries, prefix: string): string[];
|
|
654
|
+
|
|
655
|
+
/**
|
|
656
|
+
* Round-trip preservation of package parts the core model does not understand.
|
|
657
|
+
*
|
|
658
|
+
* `Workbook.saveAsBuffer()` rebuilds the package from the in-memory model, so
|
|
659
|
+
* any part core never parsed — drawings, images, themes, comments, pivot
|
|
660
|
+
* caches, docProps — would silently disappear on open→save. This module
|
|
661
|
+
* captures those parts at open time so the save pipeline can pass them through
|
|
662
|
+
* untouched.
|
|
663
|
+
*
|
|
664
|
+
* Parts core *does* own are excluded: it regenerates them, and keeping a stale
|
|
665
|
+
* copy would produce duplicates or dangling relationships.
|
|
666
|
+
*/
|
|
667
|
+
|
|
668
|
+
interface Relationship {
|
|
669
|
+
id: string;
|
|
670
|
+
type: string;
|
|
671
|
+
/** Target exactly as written in the source rels part. */
|
|
672
|
+
target: string;
|
|
673
|
+
/** Target resolved to a package-absolute path, or undefined if external. */
|
|
674
|
+
resolved?: string;
|
|
675
|
+
/** True when the relationship points outside the package (TargetMode). */
|
|
676
|
+
external: boolean;
|
|
677
|
+
}
|
|
678
|
+
|
|
615
679
|
/**
|
|
616
680
|
* Represents a rectangular range of cells for bulk operations.
|
|
617
681
|
* Port of TVE.PureDocs.Excel.Range (C#)
|
|
@@ -710,10 +774,22 @@ declare class Worksheet {
|
|
|
710
774
|
};
|
|
711
775
|
/** Sets the width of a column (1-based index). */
|
|
712
776
|
setColumnWidth(columnIndex: number, width: number): void;
|
|
777
|
+
/**
|
|
778
|
+
* Returns the explicit width of a column (1-based index), or `undefined` when
|
|
779
|
+
* the column uses the sheet default. Counterpart to {@link setColumnWidth};
|
|
780
|
+
* widths parsed from an existing file are visible here too, so column layout
|
|
781
|
+
* can be round-tripped.
|
|
782
|
+
*/
|
|
783
|
+
getColumnWidth(columnIndex: number): number | undefined;
|
|
713
784
|
/** Auto-fits column width based on content (approximate). */
|
|
714
785
|
autoFitColumn(columnIndex: number): void;
|
|
715
786
|
/** Sets the height of a row (1-based index). */
|
|
716
787
|
setRowHeight(rowIndex: number, height: number): void;
|
|
788
|
+
/**
|
|
789
|
+
* Returns the explicit height of a row (1-based index), or `undefined` when
|
|
790
|
+
* the row uses the sheet default. Counterpart to {@link setRowHeight}.
|
|
791
|
+
*/
|
|
792
|
+
getRowHeight(rowIndex: number): number | undefined;
|
|
717
793
|
/** Shows or hides a row (1-based index). Hidden rows affect SUBTOTAL(101-111). */
|
|
718
794
|
setRowHidden(rowIndex: number, hidden?: boolean): void;
|
|
719
795
|
/** True if the given 1-based row is hidden. */
|
|
@@ -722,6 +798,12 @@ declare class Worksheet {
|
|
|
722
798
|
mergeCells(rangeReference: string): void;
|
|
723
799
|
/** Removes a merge for the given range reference. */
|
|
724
800
|
unmergeCells(rangeReference: string): void;
|
|
801
|
+
/**
|
|
802
|
+
* All merged ranges on this sheet, in the order they were added (or parsed).
|
|
803
|
+
* Includes merges read from an existing file, so callers never need to track
|
|
804
|
+
* their own copy of the list.
|
|
805
|
+
*/
|
|
806
|
+
get merges(): readonly string[];
|
|
725
807
|
/**
|
|
726
808
|
* Freezes rows and/or columns.
|
|
727
809
|
* @param row Number of rows to freeze (0 = none)
|
|
@@ -745,10 +827,39 @@ declare class Worksheet {
|
|
|
745
827
|
* save pipeline turns registered providers into valid OOXML drawing/chart parts.
|
|
746
828
|
*/
|
|
747
829
|
addDrawingProvider(provider: DrawingProvider): void;
|
|
830
|
+
/**
|
|
831
|
+
* Detaches every drawing from this worksheet — both providers added in memory
|
|
832
|
+
* and any drawing preserved from the file the workbook was opened from.
|
|
833
|
+
*
|
|
834
|
+
* Call before re-adding charts when exporting the same in-memory workbook
|
|
835
|
+
* repeatedly, otherwise each export appends another copy; call on its own to
|
|
836
|
+
* deliberately drop a chart that came from the source file.
|
|
837
|
+
*/
|
|
838
|
+
clearDrawings(): void;
|
|
748
839
|
/** True when this worksheet has at least one drawing to serialise. */
|
|
749
840
|
get hasDrawings(): boolean;
|
|
750
841
|
/** @internal — drawing providers, consumed by the save pipeline. */
|
|
751
842
|
get drawingProviders(): readonly DrawingProvider[];
|
|
843
|
+
/**
|
|
844
|
+
* @internal Relationships carried over from the source file, minus any whose
|
|
845
|
+
* leaf element is no longer emitted (a drawing replaced by live providers, or
|
|
846
|
+
* cleared outright). The save pipeline writes these into the sheet's rels.
|
|
847
|
+
*/
|
|
848
|
+
get preservedRelationships(): readonly Relationship[];
|
|
849
|
+
/**
|
|
850
|
+
* @internal Package paths of relationships that were preserved at load time
|
|
851
|
+
* but are no longer referenced — a drawing replaced by live providers, or one
|
|
852
|
+
* cleared outright. The save pipeline prunes these parts so the output has no
|
|
853
|
+
* orphans.
|
|
854
|
+
*/
|
|
855
|
+
get droppedPreservedTargets(): readonly string[];
|
|
856
|
+
/**
|
|
857
|
+
* @internal Relationship id for a drawing built from live providers. Chosen to
|
|
858
|
+
* clear every preserved id so the two sets cannot collide.
|
|
859
|
+
*/
|
|
860
|
+
get drawingRelId(): string;
|
|
861
|
+
/** @internal Captures round-trip state from the source package. */
|
|
862
|
+
loadPreservedState(worksheetXml: string, relationships: readonly Relationship[]): void;
|
|
752
863
|
/** Builds the xl/worksheets/sheetN.xml string. */
|
|
753
864
|
buildXml(): string;
|
|
754
865
|
/** Parses xl/worksheets/sheetN.xml and loads cells into memory. */
|
|
@@ -835,6 +946,15 @@ declare class Workbook {
|
|
|
835
946
|
* Mirrors workbook.AddWorksheet(name) in C#.
|
|
836
947
|
*/
|
|
837
948
|
addWorksheet(name: string): Worksheet;
|
|
949
|
+
/**
|
|
950
|
+
* Removes the worksheet with the given name, along with any defined names
|
|
951
|
+
* scoped to it. Throws if the sheet does not exist or is the last remaining
|
|
952
|
+
* one — a workbook must always keep at least one sheet.
|
|
953
|
+
*
|
|
954
|
+
* Sheet ids and relationship ids are re-derived from document order on save,
|
|
955
|
+
* so the remaining sheets stay consistent after a removal.
|
|
956
|
+
*/
|
|
957
|
+
removeWorksheet(name: string): void;
|
|
838
958
|
/**
|
|
839
959
|
* Returns a worksheet by name. Throws if not found.
|
|
840
960
|
*/
|
|
@@ -972,6 +1092,27 @@ declare function isDateFormatId(formatId: number): boolean;
|
|
|
972
1092
|
*/
|
|
973
1093
|
declare function isDateFormatCode(formatCode: string): boolean;
|
|
974
1094
|
|
|
1095
|
+
/**
|
|
1096
|
+
* Renders a numeric value through an OOXML number-format code.
|
|
1097
|
+
*
|
|
1098
|
+
* Deliberately a *subset* of the full spec — it covers the codes an editor
|
|
1099
|
+
* actually round-trips (integers, fixed decimals, thousands separators,
|
|
1100
|
+
* currency, percentages, and positive/negative/zero sections) and returns
|
|
1101
|
+
* `null` for anything it does not understand, so callers can fall back to the
|
|
1102
|
+
* raw value rather than display something wrong.
|
|
1103
|
+
*
|
|
1104
|
+
* Not handled (returns null): fractions (`# ?/?`), scientific (`0.00E+00`),
|
|
1105
|
+
* date/time codes (handled by the date path in Cell), and conditional sections
|
|
1106
|
+
* such as `[<=9999999]###-####`.
|
|
1107
|
+
*/
|
|
1108
|
+
/**
|
|
1109
|
+
* Applies `formatCode` to `value`.
|
|
1110
|
+
*
|
|
1111
|
+
* @returns the formatted string, or `null` when the code is outside the
|
|
1112
|
+
* supported subset (caller should fall back to the raw value).
|
|
1113
|
+
*/
|
|
1114
|
+
declare function formatNumberWithCode(value: number, formatCode: string): string | null;
|
|
1115
|
+
|
|
975
1116
|
/**
|
|
976
1117
|
* Cross-platform XML parser.
|
|
977
1118
|
*
|
|
@@ -1067,34 +1208,6 @@ declare const CONTENT_TYPES: {
|
|
|
1067
1208
|
readonly coreProperties: "application/vnd.openxmlformats-package.core-properties+xml";
|
|
1068
1209
|
};
|
|
1069
1210
|
|
|
1070
|
-
/**
|
|
1071
|
-
* Represents the contents of an unzipped xlsx file.
|
|
1072
|
-
* Keys are file paths within the archive (e.g. "xl/workbook.xml").
|
|
1073
|
-
* Values are raw UTF-8 bytes.
|
|
1074
|
-
*/
|
|
1075
|
-
type ZipEntries = Map<string, Uint8Array>;
|
|
1076
|
-
/**
|
|
1077
|
-
* Unzips an xlsx file buffer into a map of path → bytes.
|
|
1078
|
-
*
|
|
1079
|
-
* @param buffer - ArrayBuffer or Uint8Array of the xlsx file
|
|
1080
|
-
* @returns Map of file paths to their raw bytes
|
|
1081
|
-
*/
|
|
1082
|
-
declare function unzipXlsx(buffer: ArrayBuffer | Uint8Array): ZipEntries;
|
|
1083
|
-
/**
|
|
1084
|
-
* Reads and decodes a UTF-8 text entry from a zip archive.
|
|
1085
|
-
* Returns undefined if the entry does not exist.
|
|
1086
|
-
*/
|
|
1087
|
-
declare function readXmlEntry(entries: ZipEntries, path: string): string | undefined;
|
|
1088
|
-
/**
|
|
1089
|
-
* Reads and decodes a UTF-8 text entry, throwing if missing.
|
|
1090
|
-
*/
|
|
1091
|
-
declare function requireXmlEntry(entries: ZipEntries, path: string): string;
|
|
1092
|
-
/**
|
|
1093
|
-
* Returns all entry paths that match the given prefix.
|
|
1094
|
-
* Useful for listing worksheets: prefix = "xl/worksheets/".
|
|
1095
|
-
*/
|
|
1096
|
-
declare function listEntries(entries: ZipEntries, prefix: string): string[];
|
|
1097
|
-
|
|
1098
1211
|
/**
|
|
1099
1212
|
* Represents the file entries to be zipped.
|
|
1100
1213
|
* Keys are paths within the archive, values are either bytes or a UTF-8 string.
|
|
@@ -1116,4 +1229,4 @@ declare function setXmlEntry(entries: ZipInput, path: string, xml: string): void
|
|
|
1116
1229
|
*/
|
|
1117
1230
|
declare function setBinaryEntry(entries: ZipInput, path: string, bytes: Uint8Array): void;
|
|
1118
1231
|
|
|
1119
|
-
export { CONTENT_TYPES, Cell, type CellData, CellStyle, type CellValue, type ColorXmlAttrs, type DefinedName, DefinedNameManager, type DrawingDependentPart, type DrawingProvider, ExcelAlignment, ExcelBorder, ExcelBorderEdge, ExcelBorderStyle, ExcelColor, ExcelFill, ExcelFont, type ExcelFontOptions, ExcelHorizontalAlignment, ExcelNumberFormat, ExcelPatternType, ExcelReadingOrder, ExcelUnderline, ExcelVerticalAlignRun, ExcelVerticalAlignment, NS, type ParsedCellRef, REL_TYPES, Range, type SheetVisibility, StyleManager, WORKSHEET_DRAWING_REL_ID, Workbook, Worksheet, type XmlAttrs, XmlBuilder, type XmlElement, type ZipEntries, type ZipInput, buildDrawingXml, buildRelsXml, cellRefFromRowCol, columnLetter, columnNumber, decodeUtf8, encodeUtf8, escapeXml, fromOADate, getAttr, getElementsByTagName, isDateFormatCode, isDateFormatId, listEntries, parseCellRef, parseRangeRef, parseXml, readXmlEntry, requireXmlEntry, setBinaryEntry, setXmlEntry, toOADate, unzipXlsx, xml, zipXlsx };
|
|
1232
|
+
export { CONTENT_TYPES, Cell, type CellData, CellStyle, type CellValue, type ColorXmlAttrs, type DefinedName, DefinedNameManager, type DrawingDependentPart, type DrawingProvider, ExcelAlignment, ExcelBorder, ExcelBorderEdge, ExcelBorderStyle, ExcelColor, ExcelFill, ExcelFont, type ExcelFontOptions, ExcelHorizontalAlignment, ExcelNumberFormat, ExcelPatternType, ExcelReadingOrder, ExcelUnderline, ExcelVerticalAlignRun, ExcelVerticalAlignment, NS, type ParsedCellRef, REL_TYPES, Range, type SheetVisibility, StyleManager, WORKSHEET_DRAWING_REL_ID, Workbook, Worksheet, type XmlAttrs, XmlBuilder, type XmlElement, type ZipEntries, type ZipInput, buildDrawingXml, buildRelsXml, cellRefFromRowCol, columnLetter, columnNumber, decodeUtf8, encodeUtf8, escapeXml, formatNumberWithCode, fromOADate, getAttr, getElementsByTagName, isDateFormatCode, isDateFormatId, listEntries, parseCellRef, parseRangeRef, parseXml, readXmlEntry, requireXmlEntry, setBinaryEntry, setXmlEntry, toOADate, unzipXlsx, xml, zipXlsx };
|
package/dist/index.d.ts
CHANGED
|
@@ -506,8 +506,20 @@ declare class Cell {
|
|
|
506
506
|
getValue(): CellValue;
|
|
507
507
|
/**
|
|
508
508
|
* Returns the display text of the cell value (always a string).
|
|
509
|
+
*
|
|
510
|
+
* Numbers are returned unformatted; use {@link getFormattedText} to apply the
|
|
511
|
+
* cell's number format.
|
|
509
512
|
*/
|
|
510
513
|
getText(): string;
|
|
514
|
+
/**
|
|
515
|
+
* Returns the display text with the cell's number format applied, e.g. a
|
|
516
|
+
* value of 4.5 under `$#,##0.00` renders as `$4.50`.
|
|
517
|
+
*
|
|
518
|
+
* Falls back to {@link getText} for non-numeric values and for format codes
|
|
519
|
+
* outside the supported subset (fractions, scientific notation, conditional
|
|
520
|
+
* sections) — so the result is never a misleading rendering.
|
|
521
|
+
*/
|
|
522
|
+
getFormattedText(): string;
|
|
511
523
|
/**
|
|
512
524
|
* Sets a formula. The leading '=' is optional.
|
|
513
525
|
* Clears any cached value.
|
|
@@ -612,6 +624,58 @@ declare function buildDrawingXml(anchorsXml: string): string;
|
|
|
612
624
|
/** Builds a generic `.rels` part from a list of `<Relationship .../>` strings. */
|
|
613
625
|
declare function buildRelsXml(relationships: readonly string[]): string;
|
|
614
626
|
|
|
627
|
+
/**
|
|
628
|
+
* Represents the contents of an unzipped xlsx file.
|
|
629
|
+
* Keys are file paths within the archive (e.g. "xl/workbook.xml").
|
|
630
|
+
* Values are raw UTF-8 bytes.
|
|
631
|
+
*/
|
|
632
|
+
type ZipEntries = Map<string, Uint8Array>;
|
|
633
|
+
/**
|
|
634
|
+
* Unzips an xlsx file buffer into a map of path → bytes.
|
|
635
|
+
*
|
|
636
|
+
* @param buffer - ArrayBuffer or Uint8Array of the xlsx file
|
|
637
|
+
* @returns Map of file paths to their raw bytes
|
|
638
|
+
*/
|
|
639
|
+
declare function unzipXlsx(buffer: ArrayBuffer | Uint8Array): ZipEntries;
|
|
640
|
+
/**
|
|
641
|
+
* Reads and decodes a UTF-8 text entry from a zip archive.
|
|
642
|
+
* Returns undefined if the entry does not exist.
|
|
643
|
+
*/
|
|
644
|
+
declare function readXmlEntry(entries: ZipEntries, path: string): string | undefined;
|
|
645
|
+
/**
|
|
646
|
+
* Reads and decodes a UTF-8 text entry, throwing if missing.
|
|
647
|
+
*/
|
|
648
|
+
declare function requireXmlEntry(entries: ZipEntries, path: string): string;
|
|
649
|
+
/**
|
|
650
|
+
* Returns all entry paths that match the given prefix.
|
|
651
|
+
* Useful for listing worksheets: prefix = "xl/worksheets/".
|
|
652
|
+
*/
|
|
653
|
+
declare function listEntries(entries: ZipEntries, prefix: string): string[];
|
|
654
|
+
|
|
655
|
+
/**
|
|
656
|
+
* Round-trip preservation of package parts the core model does not understand.
|
|
657
|
+
*
|
|
658
|
+
* `Workbook.saveAsBuffer()` rebuilds the package from the in-memory model, so
|
|
659
|
+
* any part core never parsed — drawings, images, themes, comments, pivot
|
|
660
|
+
* caches, docProps — would silently disappear on open→save. This module
|
|
661
|
+
* captures those parts at open time so the save pipeline can pass them through
|
|
662
|
+
* untouched.
|
|
663
|
+
*
|
|
664
|
+
* Parts core *does* own are excluded: it regenerates them, and keeping a stale
|
|
665
|
+
* copy would produce duplicates or dangling relationships.
|
|
666
|
+
*/
|
|
667
|
+
|
|
668
|
+
interface Relationship {
|
|
669
|
+
id: string;
|
|
670
|
+
type: string;
|
|
671
|
+
/** Target exactly as written in the source rels part. */
|
|
672
|
+
target: string;
|
|
673
|
+
/** Target resolved to a package-absolute path, or undefined if external. */
|
|
674
|
+
resolved?: string;
|
|
675
|
+
/** True when the relationship points outside the package (TargetMode). */
|
|
676
|
+
external: boolean;
|
|
677
|
+
}
|
|
678
|
+
|
|
615
679
|
/**
|
|
616
680
|
* Represents a rectangular range of cells for bulk operations.
|
|
617
681
|
* Port of TVE.PureDocs.Excel.Range (C#)
|
|
@@ -710,10 +774,22 @@ declare class Worksheet {
|
|
|
710
774
|
};
|
|
711
775
|
/** Sets the width of a column (1-based index). */
|
|
712
776
|
setColumnWidth(columnIndex: number, width: number): void;
|
|
777
|
+
/**
|
|
778
|
+
* Returns the explicit width of a column (1-based index), or `undefined` when
|
|
779
|
+
* the column uses the sheet default. Counterpart to {@link setColumnWidth};
|
|
780
|
+
* widths parsed from an existing file are visible here too, so column layout
|
|
781
|
+
* can be round-tripped.
|
|
782
|
+
*/
|
|
783
|
+
getColumnWidth(columnIndex: number): number | undefined;
|
|
713
784
|
/** Auto-fits column width based on content (approximate). */
|
|
714
785
|
autoFitColumn(columnIndex: number): void;
|
|
715
786
|
/** Sets the height of a row (1-based index). */
|
|
716
787
|
setRowHeight(rowIndex: number, height: number): void;
|
|
788
|
+
/**
|
|
789
|
+
* Returns the explicit height of a row (1-based index), or `undefined` when
|
|
790
|
+
* the row uses the sheet default. Counterpart to {@link setRowHeight}.
|
|
791
|
+
*/
|
|
792
|
+
getRowHeight(rowIndex: number): number | undefined;
|
|
717
793
|
/** Shows or hides a row (1-based index). Hidden rows affect SUBTOTAL(101-111). */
|
|
718
794
|
setRowHidden(rowIndex: number, hidden?: boolean): void;
|
|
719
795
|
/** True if the given 1-based row is hidden. */
|
|
@@ -722,6 +798,12 @@ declare class Worksheet {
|
|
|
722
798
|
mergeCells(rangeReference: string): void;
|
|
723
799
|
/** Removes a merge for the given range reference. */
|
|
724
800
|
unmergeCells(rangeReference: string): void;
|
|
801
|
+
/**
|
|
802
|
+
* All merged ranges on this sheet, in the order they were added (or parsed).
|
|
803
|
+
* Includes merges read from an existing file, so callers never need to track
|
|
804
|
+
* their own copy of the list.
|
|
805
|
+
*/
|
|
806
|
+
get merges(): readonly string[];
|
|
725
807
|
/**
|
|
726
808
|
* Freezes rows and/or columns.
|
|
727
809
|
* @param row Number of rows to freeze (0 = none)
|
|
@@ -745,10 +827,39 @@ declare class Worksheet {
|
|
|
745
827
|
* save pipeline turns registered providers into valid OOXML drawing/chart parts.
|
|
746
828
|
*/
|
|
747
829
|
addDrawingProvider(provider: DrawingProvider): void;
|
|
830
|
+
/**
|
|
831
|
+
* Detaches every drawing from this worksheet — both providers added in memory
|
|
832
|
+
* and any drawing preserved from the file the workbook was opened from.
|
|
833
|
+
*
|
|
834
|
+
* Call before re-adding charts when exporting the same in-memory workbook
|
|
835
|
+
* repeatedly, otherwise each export appends another copy; call on its own to
|
|
836
|
+
* deliberately drop a chart that came from the source file.
|
|
837
|
+
*/
|
|
838
|
+
clearDrawings(): void;
|
|
748
839
|
/** True when this worksheet has at least one drawing to serialise. */
|
|
749
840
|
get hasDrawings(): boolean;
|
|
750
841
|
/** @internal — drawing providers, consumed by the save pipeline. */
|
|
751
842
|
get drawingProviders(): readonly DrawingProvider[];
|
|
843
|
+
/**
|
|
844
|
+
* @internal Relationships carried over from the source file, minus any whose
|
|
845
|
+
* leaf element is no longer emitted (a drawing replaced by live providers, or
|
|
846
|
+
* cleared outright). The save pipeline writes these into the sheet's rels.
|
|
847
|
+
*/
|
|
848
|
+
get preservedRelationships(): readonly Relationship[];
|
|
849
|
+
/**
|
|
850
|
+
* @internal Package paths of relationships that were preserved at load time
|
|
851
|
+
* but are no longer referenced — a drawing replaced by live providers, or one
|
|
852
|
+
* cleared outright. The save pipeline prunes these parts so the output has no
|
|
853
|
+
* orphans.
|
|
854
|
+
*/
|
|
855
|
+
get droppedPreservedTargets(): readonly string[];
|
|
856
|
+
/**
|
|
857
|
+
* @internal Relationship id for a drawing built from live providers. Chosen to
|
|
858
|
+
* clear every preserved id so the two sets cannot collide.
|
|
859
|
+
*/
|
|
860
|
+
get drawingRelId(): string;
|
|
861
|
+
/** @internal Captures round-trip state from the source package. */
|
|
862
|
+
loadPreservedState(worksheetXml: string, relationships: readonly Relationship[]): void;
|
|
752
863
|
/** Builds the xl/worksheets/sheetN.xml string. */
|
|
753
864
|
buildXml(): string;
|
|
754
865
|
/** Parses xl/worksheets/sheetN.xml and loads cells into memory. */
|
|
@@ -835,6 +946,15 @@ declare class Workbook {
|
|
|
835
946
|
* Mirrors workbook.AddWorksheet(name) in C#.
|
|
836
947
|
*/
|
|
837
948
|
addWorksheet(name: string): Worksheet;
|
|
949
|
+
/**
|
|
950
|
+
* Removes the worksheet with the given name, along with any defined names
|
|
951
|
+
* scoped to it. Throws if the sheet does not exist or is the last remaining
|
|
952
|
+
* one — a workbook must always keep at least one sheet.
|
|
953
|
+
*
|
|
954
|
+
* Sheet ids and relationship ids are re-derived from document order on save,
|
|
955
|
+
* so the remaining sheets stay consistent after a removal.
|
|
956
|
+
*/
|
|
957
|
+
removeWorksheet(name: string): void;
|
|
838
958
|
/**
|
|
839
959
|
* Returns a worksheet by name. Throws if not found.
|
|
840
960
|
*/
|
|
@@ -972,6 +1092,27 @@ declare function isDateFormatId(formatId: number): boolean;
|
|
|
972
1092
|
*/
|
|
973
1093
|
declare function isDateFormatCode(formatCode: string): boolean;
|
|
974
1094
|
|
|
1095
|
+
/**
|
|
1096
|
+
* Renders a numeric value through an OOXML number-format code.
|
|
1097
|
+
*
|
|
1098
|
+
* Deliberately a *subset* of the full spec — it covers the codes an editor
|
|
1099
|
+
* actually round-trips (integers, fixed decimals, thousands separators,
|
|
1100
|
+
* currency, percentages, and positive/negative/zero sections) and returns
|
|
1101
|
+
* `null` for anything it does not understand, so callers can fall back to the
|
|
1102
|
+
* raw value rather than display something wrong.
|
|
1103
|
+
*
|
|
1104
|
+
* Not handled (returns null): fractions (`# ?/?`), scientific (`0.00E+00`),
|
|
1105
|
+
* date/time codes (handled by the date path in Cell), and conditional sections
|
|
1106
|
+
* such as `[<=9999999]###-####`.
|
|
1107
|
+
*/
|
|
1108
|
+
/**
|
|
1109
|
+
* Applies `formatCode` to `value`.
|
|
1110
|
+
*
|
|
1111
|
+
* @returns the formatted string, or `null` when the code is outside the
|
|
1112
|
+
* supported subset (caller should fall back to the raw value).
|
|
1113
|
+
*/
|
|
1114
|
+
declare function formatNumberWithCode(value: number, formatCode: string): string | null;
|
|
1115
|
+
|
|
975
1116
|
/**
|
|
976
1117
|
* Cross-platform XML parser.
|
|
977
1118
|
*
|
|
@@ -1067,34 +1208,6 @@ declare const CONTENT_TYPES: {
|
|
|
1067
1208
|
readonly coreProperties: "application/vnd.openxmlformats-package.core-properties+xml";
|
|
1068
1209
|
};
|
|
1069
1210
|
|
|
1070
|
-
/**
|
|
1071
|
-
* Represents the contents of an unzipped xlsx file.
|
|
1072
|
-
* Keys are file paths within the archive (e.g. "xl/workbook.xml").
|
|
1073
|
-
* Values are raw UTF-8 bytes.
|
|
1074
|
-
*/
|
|
1075
|
-
type ZipEntries = Map<string, Uint8Array>;
|
|
1076
|
-
/**
|
|
1077
|
-
* Unzips an xlsx file buffer into a map of path → bytes.
|
|
1078
|
-
*
|
|
1079
|
-
* @param buffer - ArrayBuffer or Uint8Array of the xlsx file
|
|
1080
|
-
* @returns Map of file paths to their raw bytes
|
|
1081
|
-
*/
|
|
1082
|
-
declare function unzipXlsx(buffer: ArrayBuffer | Uint8Array): ZipEntries;
|
|
1083
|
-
/**
|
|
1084
|
-
* Reads and decodes a UTF-8 text entry from a zip archive.
|
|
1085
|
-
* Returns undefined if the entry does not exist.
|
|
1086
|
-
*/
|
|
1087
|
-
declare function readXmlEntry(entries: ZipEntries, path: string): string | undefined;
|
|
1088
|
-
/**
|
|
1089
|
-
* Reads and decodes a UTF-8 text entry, throwing if missing.
|
|
1090
|
-
*/
|
|
1091
|
-
declare function requireXmlEntry(entries: ZipEntries, path: string): string;
|
|
1092
|
-
/**
|
|
1093
|
-
* Returns all entry paths that match the given prefix.
|
|
1094
|
-
* Useful for listing worksheets: prefix = "xl/worksheets/".
|
|
1095
|
-
*/
|
|
1096
|
-
declare function listEntries(entries: ZipEntries, prefix: string): string[];
|
|
1097
|
-
|
|
1098
1211
|
/**
|
|
1099
1212
|
* Represents the file entries to be zipped.
|
|
1100
1213
|
* Keys are paths within the archive, values are either bytes or a UTF-8 string.
|
|
@@ -1116,4 +1229,4 @@ declare function setXmlEntry(entries: ZipInput, path: string, xml: string): void
|
|
|
1116
1229
|
*/
|
|
1117
1230
|
declare function setBinaryEntry(entries: ZipInput, path: string, bytes: Uint8Array): void;
|
|
1118
1231
|
|
|
1119
|
-
export { CONTENT_TYPES, Cell, type CellData, CellStyle, type CellValue, type ColorXmlAttrs, type DefinedName, DefinedNameManager, type DrawingDependentPart, type DrawingProvider, ExcelAlignment, ExcelBorder, ExcelBorderEdge, ExcelBorderStyle, ExcelColor, ExcelFill, ExcelFont, type ExcelFontOptions, ExcelHorizontalAlignment, ExcelNumberFormat, ExcelPatternType, ExcelReadingOrder, ExcelUnderline, ExcelVerticalAlignRun, ExcelVerticalAlignment, NS, type ParsedCellRef, REL_TYPES, Range, type SheetVisibility, StyleManager, WORKSHEET_DRAWING_REL_ID, Workbook, Worksheet, type XmlAttrs, XmlBuilder, type XmlElement, type ZipEntries, type ZipInput, buildDrawingXml, buildRelsXml, cellRefFromRowCol, columnLetter, columnNumber, decodeUtf8, encodeUtf8, escapeXml, fromOADate, getAttr, getElementsByTagName, isDateFormatCode, isDateFormatId, listEntries, parseCellRef, parseRangeRef, parseXml, readXmlEntry, requireXmlEntry, setBinaryEntry, setXmlEntry, toOADate, unzipXlsx, xml, zipXlsx };
|
|
1232
|
+
export { CONTENT_TYPES, Cell, type CellData, CellStyle, type CellValue, type ColorXmlAttrs, type DefinedName, DefinedNameManager, type DrawingDependentPart, type DrawingProvider, ExcelAlignment, ExcelBorder, ExcelBorderEdge, ExcelBorderStyle, ExcelColor, ExcelFill, ExcelFont, type ExcelFontOptions, ExcelHorizontalAlignment, ExcelNumberFormat, ExcelPatternType, ExcelReadingOrder, ExcelUnderline, ExcelVerticalAlignRun, ExcelVerticalAlignment, NS, type ParsedCellRef, REL_TYPES, Range, type SheetVisibility, StyleManager, WORKSHEET_DRAWING_REL_ID, Workbook, Worksheet, type XmlAttrs, XmlBuilder, type XmlElement, type ZipEntries, type ZipInput, buildDrawingXml, buildRelsXml, cellRefFromRowCol, columnLetter, columnNumber, decodeUtf8, encodeUtf8, escapeXml, formatNumberWithCode, fromOADate, getAttr, getElementsByTagName, isDateFormatCode, isDateFormatId, listEntries, parseCellRef, parseRangeRef, parseXml, readXmlEntry, requireXmlEntry, setBinaryEntry, setXmlEntry, toOADate, unzipXlsx, xml, zipXlsx };
|