import type { Cell } from '../cell/cell'; import type { Workbook } from '../workbook/workbook'; import { type Worksheet } from '../worksheet/worksheet'; import type { Alignment, HorizontalAlignment, VerticalAlignment } from './alignment'; import type { Border, SideStyle } from './borders'; import type { Color } from './colors'; import type { Fill } from './fills'; import type { Font, UnderlineStyle } from './fonts'; import type { Protection } from './protection'; export declare function getCellFont(wb: Workbook, c: Cell): Font; export declare function getCellFill(wb: Workbook, c: Cell): Fill; export declare function getCellBorder(wb: Workbook, c: Cell): Border; export declare function getCellAlignment(wb: Workbook, c: Cell): Alignment; export declare function getCellProtection(wb: Workbook, c: Cell): Protection; /** * Returns the cell's number-format **code** (e.g. `"0.00"`, `"General"`). * Built-in IDs resolve through `builtinFormatCode`; custom IDs come from the * workbook's numFmts map. */ export declare function getCellNumberFormat(wb: Workbook, c: Cell): string; /** * Aggregate `fontToCss` + `fillToCss` + `borderToCss` + `alignmentToCss` for a * cell into a single CSS-property record. Resolves the cell's `styleId` against * the workbook stylesheet, then merges the four partials. On key collision the * priority is alignment > border > fill > font (alignment is most specific, * font is the broad default). A fully-default cell (`styleId === 0` with empty * pools) returns `{}`. */ export declare function cellStyleToCss(wb: Workbook, c: Cell): Record; export declare function setCellFont(wb: Workbook, c: Cell, font: Font): void; export declare function setCellFill(wb: Workbook, c: Cell, fill: Fill): void; export declare function setCellBorder(wb: Workbook, c: Cell, border: Border): void; export declare function setCellAlignment(wb: Workbook, c: Cell, alignment: Alignment): void; export declare function setCellProtection(wb: Workbook, c: Cell, protection: Protection): void; /** * Set the cell's number format by its **code** string. Built-in codes resolve * to their canonical id; custom codes are registered via `addNumFmt`. */ export declare function setCellNumberFormat(wb: Workbook, c: Cell, formatCode: string): void; /** * Copy the source cell's `styleId` to the target cell. Both cells share the * same workbook stylesheet, so the styled appearance carries over without * allocating a new xf entry. Pass cells from different workbooks via {@link * cloneCellStyle} if you need a deep copy across workbooks. */ export declare function copyCellStyle(_wb: Workbook, source: Cell, target: Cell): void; /** * Reset a cell back to the default (unstyled) appearance — equivalent to * Excel's "Clear Formatting" command. After the call, the cell inherits the * workbook's default font / fill / border / alignment / protection / * numberFormat. The underlying xf pool is **not** shrunk (Excel doesn't bother * either; the orphaned xf is harmless). */ export declare function clearCellStyle(_wb: Workbook, c: Cell): void; /** * Range-level shortcut for {@link clearCellStyle}. Walks every cell actually * present in the range and resets its `styleId` to 0; cells that don't exist * yet are **not** materialised (no-op for sparse regions, unlike the styled * `setRange*` family which has to create cells to make the patch observable). */ export declare function clearRangeStyle(wb: Workbook, ws: Worksheet, range: string): void; /** * Deep-copy the source cell's full xf (font / fill / border / alignment / * protection / numberFormat) into a possibly-different workbook. Returns the * new styleId in the target workbook. */ export declare function cloneCellStyle(sourceWb: Workbook, source: Cell, targetWb: Workbook, target: Cell): number; /** * Build a single CellXf id from a multi-axis style spec, then apply it to every * cell in `range`. The xf is registered once per style shape, so a 1000-cell * range allocates one xf — much faster than looping `setCellStyle` per cell. */ export declare function setRangeStyle(wb: Workbook, ws: Worksheet, range: string, opts: { font?: Font; fill?: Fill; border?: Border; alignment?: Alignment; protection?: Protection; numberFormat?: string; }): void; /** * Combined cell-style setter. Each axis is independent — pass any subset and * the corresponding `applyXxx` flags get set on the underlying CellXf. Avoids * 5+ separate stylesheet round-trips when a caller wants to style a single cell * across multiple axes (Excel dedupes the resulting xf record on every call). */ export declare function setCellStyle(wb: Workbook, c: Cell, opts: { font?: Font; fill?: Fill; border?: Border; alignment?: Alignment; protection?: Protection; numberFormat?: string; }): void; /** * Set the cell's background to a solid color. Accepts a hex string * (`'FFAAFFAA'`) or a partial `Color` object (`{ theme: 4, tint: 0.4 }`). * Equivalent to `setCellFill(wb, c, makePatternFill({ patternType: 'solid', * fgColor: makeColor(...) }))`. */ export declare function setCellBackgroundColor(wb: Workbook, c: Cell, color: string | Partial): void; /** Strip the cell's background fill, returning it to the default. */ export declare function clearCellBackground(wb: Workbook, c: Cell): void; /** * Range-level shortcut for `setCellBackgroundColor`. Each cell in the range * gets the same solid pattern fill via `setRangeStyle`, so the fill pool dedups * to a single entry across the whole range. */ export declare function setRangeBackgroundColor(wb: Workbook, ws: Worksheet, range: string, color: string | Partial): void; /** Range-level shortcut for `setCellFont` (full Font replacement). */ export declare function setRangeFont(wb: Workbook, ws: Worksheet, range: string, font: Font): void; /** * Range-level shortcut for `setCellNumberFormat`. Stamps the same format-code * onto every cell in the range; the numFmt pool dedups the code so callers * don't pay per-cell pool churn. */ export declare function setRangeNumberFormat(wb: Workbook, ws: Worksheet, range: string, formatCode: string): void; /** * Range-level shortcut for `setCellProtection`. Stamps the same Protection * (locked / hidden) onto every cell in the range. Pass a full `Protection` * value or a partial — partials default missing fields to `false` per Excel's * `` semantics. * * Common usage: `setRangeProtection(wb, ws, 'B2:B100', { locked: false })` to * leave just an input column editable when the sheet is protected. */ export declare function setRangeProtection(wb: Workbook, ws: Worksheet, range: string, protection: Protection | Partial): void; /** * Range-level shortcut for `wrapCellText`. Toggles "Wrap Text" on every cell in * the range while preserving each cell's existing alignment (horizontal / * vertical / textRotation / indent are not touched). Empty cells in the range * are materialised so the alignment patch is observable on round-trip. */ export declare function setRangeWrapText(wb: Workbook, ws: Worksheet, range: string, on?: boolean): void; /** * Range-level Alignment setter. Two modes: * * - `mode: 'merge'` (default) — each cell's existing alignment is * preserved; the supplied partial overlays it. Use this when you * want to set just `horizontal` or `vertical` without wiping the * other axes. * - `mode: 'replace'` — each cell's alignment is **wholly replaced** * by the supplied value. Indent / textRotation / wrapText that * weren't supplied are dropped. * * Empty cells in the range are materialised so the patch is observable on * round-trip. */ export declare function setRangeAlignment(wb: Workbook, ws: Worksheet, range: string, alignment: Partial, mode?: 'merge' | 'replace'): void; /** Toggle bold on a cell. Preserves other font fields. */ export declare function setBold(wb: Workbook, c: Cell, on?: boolean): void; /** Toggle italic on a cell. */ export declare function setItalic(wb: Workbook, c: Cell, on?: boolean): void; /** Toggle strike-through on a cell. */ export declare function setStrikethrough(wb: Workbook, c: Cell, on?: boolean): void; /** * Set the underline style. Pass `false` to drop underline; pass `'single' | * 'double' | 'singleAccounting' | 'doubleAccounting'` to apply that style; pass * `true` for the most common single-line. */ export declare function setUnderline(wb: Workbook, c: Cell, style?: UnderlineStyle | boolean): void; /** Set the font size in points (e.g. 14). Preserves other fields. */ export declare function setFontSize(wb: Workbook, c: Cell, size: number): void; /** Set the font family name (e.g. "Arial"). Preserves other fields. */ export declare function setFontName(wb: Workbook, c: Cell, name: string): void; /** * Set the font color. Accepts a hex string ("FFAA0033") or a partial `Color` * object (`{ theme: 4, tint: 0.4 }`). Preserves other font fields. */ export declare function setFontColor(wb: Workbook, c: Cell, color: string | Partial): void; /** * Center a cell horizontally + vertically. Mirrors Excel's "Merge & Center" UI * button (without the merge — see {@link mergeCells} for that). Preserves any * other alignment fields already present. */ export declare function centerCell(wb: Workbook, c: Cell): void; /** Toggle "Wrap Text" on a cell, preserving other alignment fields. */ export declare function wrapCellText(wb: Workbook, c: Cell, wrap?: boolean): void; /** Set the horizontal alignment in isolation. */ export declare function alignCellHorizontal(wb: Workbook, c: Cell, horizontal: HorizontalAlignment): void; /** Set the vertical alignment in isolation. */ export declare function alignCellVertical(wb: Workbook, c: Cell, vertical: VerticalAlignment): void; /** * Rotate the cell's text. `degrees` accepts 0..180 (clockwise) or 255 for * Excel's "vertical stacked" mode. Mirrors the rotate icons in the alignment * ribbon. */ export declare function rotateCellText(wb: Workbook, c: Cell, degrees: number): void; /** Set or clear the indent level (0..255). */ export declare function indentCell(wb: Workbook, c: Cell, levels: number): void; /** * Format a cell as currency. Produces one of: * - default → `"$#,##0.00"` (US dollar, 2 decimals) * - `{ symbol: "€" }` → `"€#,##0.00"` * - `{ symbol: "¥", decimals: 0 }` → `"¥#,##0"` * - `{ accounting: true }` → `"_-$* #,##0.00_-;-$* #,##0.00_-;_-$* \"-\"??_-;_-@_-"` * (Excel's "Accounting" subtype with right-aligned symbol). */ export declare function setCellAsCurrency(wb: Workbook, c: Cell, opts?: { symbol?: string; decimals?: number; accounting?: boolean; }): void; /** * Format a cell as a percentage. `decimals` defaults to 0 → `"0%"`; `decimals: * 2` → `"0.00%"`. The cell value is multiplied by 100 by Excel during display. */ export declare function setCellAsPercent(wb: Workbook, c: Cell, decimals?: number): void; /** * Format a cell as a date. `format` defaults to Excel's default * locale-independent ISO-style date `"yyyy-mm-dd"`. Common alternatives: * `"m/d/yyyy"`, `"dd-mmm-yy"`, `"yyyy-mm-dd hh:mm:ss"`. */ export declare function setCellAsDate(wb: Workbook, c: Cell, format?: string): void; /** * Format a cell as a thousands-separated number. `decimals` defaults to 0 → * `"#,##0"`; `decimals: 2` → `"#,##0.00"`. */ export declare function setCellAsNumber(wb: Workbook, c: Cell, decimals?: number): void; /** * Apply Excel's stock "table header" formatting to a range: bold white text on * a dark fill, plus a thick bottom border. Override any axis via `opts` — pass * `bold: false` to drop the bold, or `fillColor: 'FF305496'` for a different * shade. Defaults match Excel's "Table Style Medium 2" header row. */ export declare function formatAsHeader(wb: Workbook, ws: Worksheet, range: string, opts?: { fillColor?: string | Partial; fontColor?: string | Partial; bold?: boolean; bottomBorder?: SideStyle | false; bottomBorderColor?: string | Partial; }): void; /** * Apply a built-in Excel style ("Heading 1" / "Total" / "Good" / "Bad" / * "Calculation" / etc.) to a single cell. Registers the built-in on the * Stylesheet (idempotent) and points the cell's xf at it via `xfId` while * inheriting the matching font/fill/border/ numFmt ids so the cell renders * correctly on its own. * * Throws when `name` isn't in {@link BUILTIN_NAMED_STYLES}; use {@link * applyNamedStyle} for user-registered styles. */ export declare function applyBuiltinStyle(wb: Workbook, c: Cell, name: string): void; /** * Apply a NamedStyle that's already registered on the workbook (via * `addNamedStyle` or `ensureBuiltinStyle`) to a single cell, by name. */ export declare function applyNamedStyle(wb: Workbook, c: Cell, name: string): void; /** * Apply the same {@link SideStyle} to all four edges of a single cell. Optional * color via hex string or `Color` partial. Equivalent to `setCellBorder(wb, c, * makeBorder({ left, right, top, bottom: side }))` with all four sides * identical. */ export declare function setCellBorderAll(wb: Workbook, c: Cell, opts?: { style: SideStyle; color?: string | Partial; }): void; /** * Draw an outer border around a rectangular range. Cells on the perimeter * receive a partial border (only the edges that face outside the range); inner * cells are unaffected unless `inner` is provided, in which case every cell in * the range receives a border combining its perimeter edges with the `inner` * style for the inside edges. */ export declare function setRangeBorderBox(wb: Workbook, ws: Worksheet, range: string, opts?: { style: SideStyle; color?: string | Partial; inner?: SideStyle; }): void;