import type { GridRowId } from '@mui/x-data-grid-pro'; import type { GridStateColDef } from '@mui/x-data-grid/internals'; import type { RefObject } from '@mui/x-internals/types'; import type { GridPrivateApiPremium } from "../../../models/gridApiPremium.mjs"; import type { ExcelFormulaErrorCode, FormulaPositionContext } from "./engine/index.mjs"; /** * The cached `result` written alongside an exported Excel formula. Structurally * compatible with the exceljs fork's formula-cell value (`{ formula, result }`). */ export type ExcelFormulaResult = number | string | boolean | Date | null | { error: ExcelFormulaErrorCode; }; /** * One exported formula cell: the A1 formula string (without a leading `=` — * exceljs writes it verbatim into the `` element) and its cached result, * ready to assign to `cell.value`. */ export interface ExcelFormulaCell { formula: string; result: ExcelFormulaResult; } /** * Maps grid identities to their coordinates in the *exported* sheet. Built once * per export: the export's own column/row order and header-row offset differ * from the grid's visible order, so the A1 references baked into formulas must be * computed against this layout, not the live position context. * * `null` from `createFormulaExcelExportLayout` means no exported column accepts * formulas, so the serializer skips all formula work and the output is identical * to a value-only export. */ export interface FormulaExcelExportLayout { /** Live position context — resolves positional (`$`-absolute) refs to an identity. */ positionContext: FormulaPositionContext; /** field -> Excel column letter, in export order (`A`, `B`, …). */ fieldToColumnLetter: Map; /** stringified row id -> 1-based Excel row number (header offset included). */ rowIdToRowNumber: Map; firstDataRowNumber: number; lastDataRowNumber: number; } export declare function createFormulaExcelExportLayout(apiRef: RefObject, columns: GridStateColDef[], rowIds: GridRowId[], options: { includeHeaders: boolean; includeColumnGroupsHeaders: boolean; }): FormulaExcelExportLayout | null; /** * Computes the Excel formula cell to write for `(id, field)`, or `null` when the * cell is not a live formula (the caller then keeps the evaluated value). * * Returns `null` when: * - the cell has no evaluated formula result (`getCellFormulaResult` is the * authoritative gate — covers `allowFormulas`, `disableFormulas`/`dataSource`/ * pivot, and a genuine `=` value, and rejects a literal `=text` in a plain * column); * - the canonical source is missing or fails to parse (defensive — stored * canonical formulas should always parse); * - the formula calls a function that is not in the registry. Editing validates * function names, but raw row data does not, so an unregistered call can only * come from untrusted data — writing it as a live formula would let that data * smuggle spreadsheet-evaluated formulas (`WEBSERVICE`, `HYPERLINK`, …) into * the exported file. * * References to cells outside the export bake `#REF!` into the formula and the * result becomes `{ error: '#REF!' }` (never silently dropped). */ export declare function getCellExcelFormula(apiRef: RefObject, layout: FormulaExcelExportLayout, id: GridRowId, field: string): ExcelFormulaCell | null;