import type { HotInstance } from '../../core/types'; import type { SummaryEndpoint } from '../columnSummary/columnSummary'; interface MergeCellDescriptor { row: number; col: number; rowspan: number; colspan: number; } interface NestedHeaderTreeNodeData { columnIndex: number; origColspan: number; headerClassNames: string[]; label: string; } interface NestedHeaderSettings { isRoot: boolean; colspan: number; headerClassNames: string[]; label: string; } type NestedHeadersPluginWithState = { getStateManager(): { getHeaderTreeNodeData(layer: number, col: number): NestedHeaderTreeNodeData | null | undefined; }; }; type NestedHeadersPluginWithSettings = { getHeaderSettings(layer: number, col: number): NestedHeaderSettings | null | undefined; }; /** * @private */ declare class DataProvider { /** * Handsontable instance. * * @type {Core} */ hot: HotInstance; /** * Format type class options. * * @type {object} */ options: Record; /** * Initializes the data provider with a reference to the Handsontable instance used to retrieve data for export. */ constructor(hotInstance: HotInstance); /** * Set options for data provider. * * @param {object} options Object with specified options. */ setOptions(options: Record): void; /** * Builds a 2D array by calling `getCellValue(rowIndex, colIndex)` for every visible * cell in the export range, honouring hidden-row and hidden-column exclusions. * * @private * @param {Function} getCellValue Called for each visible cell; its return value is * pushed into the row array. * @returns {Array[]} */ _extractDataMatrix(getCellValue: (row: number, col: number) => T): T[][]; /** * Get table data based on provided settings to the class constructor. * * @returns {Array} */ getData(): unknown[][]; /** * Gets list of row headers. * * @returns {Array} */ getRowHeaders(): Array; /** * Gets list of columns headers. * * @returns {Array} */ getColumnHeaders(): string[]; /** * Get data range object based on settings provided in the class constructor. * * @private * @returns {object} Returns object with keys `startRow`, `startCol`, `endRow` and `endCol`. */ _getDataRange(): { startRow: number; startCol: number; endRow: number; endCol: number; }; /** * Get raw source data (formulas) based on provided settings to the class constructor. * * Mirrors {@link DataProvider#getData} but uses `getSourceDataAtCell` so that cells * containing HyperFormula formulas return the raw formula string (e.g. `'=SUM(A1:A3)'`) * rather than the calculated value. * * @returns {Array} */ getSourceData(): unknown[][]; /** * Returns the set of physical HOT row indices that are hidden and excluded from the * exported data matrix (i.e. `exportHiddenRows` is `false` and the row is hidden). * * Returns an empty set when `exportHiddenRows` is `true` or `'hide'`, because in * those cases all rows are included in the data matrix and no formula-offset * adjustment is needed. * * Used by the formula normalizer to adjust per-reference row offsets when building * live Excel formulas from HyperFormula formula strings. * * @returns {Set} */ getExcludedHiddenRows(): Set; /** * Returns the set of physical HOT column indices that are hidden and excluded from the * exported data matrix (i.e. `exportHiddenColumns` is `false` and the column is hidden). * * Returns an empty set when `exportHiddenColumns` is `true` or `'hide'`, because in * those cases all columns are included in the data matrix and no formula-offset * adjustment is needed. * * Used by the formula normalizer to adjust per-reference column offsets when building * live Excel formulas from HyperFormula formula strings. * * @returns {Set} */ getExcludedHiddenColumns(): Set; /** * Returns the 0-based data-array row indices for rows that are hidden in * Handsontable and are included in the exported data matrix. * * Only returns a non-empty array when `exportHiddenRows` is `'hide'`. * When `true`, all rows are visible in Excel. When `false`, hidden rows * are omitted entirely and there is nothing to mark as hidden. * * @returns {number[]} */ getHiddenRowDataIndices(): number[]; /** * Returns the 0-based data-array column indices for columns that are hidden in * Handsontable and are included in the exported data matrix. * * Only returns a non-empty array when `exportHiddenColumns` is `'hide'`. * When `true`, all columns are visible in Excel. When `false`, hidden columns * are omitted entirely and there is nothing to mark as hidden. * * @returns {number[]} */ getHiddenColumnDataIndices(): number[]; /** * Gets the function argument separator used by the HyperFormula engine, if active. * * Returns `','` when the Formulas plugin is absent or disabled, since that is the * separator OOXML (Excel) always expects. * * @returns {string} */ getFormulasSeparator(): string; /** * Gets cell meta for all cells in the export range. * * Returns a 2D array of cell meta objects with the same structure as {@link DataProvider#getData}. * Each entry corresponds to the cell at the same position in the data array. * * @returns {Array} */ getCellsMeta(): Record[][]; /** * Gets rendered DOM elements for all cells in the export range. * * Returns a 2D array of `HTMLElement | null` values with the same structure as * {@link DataProvider#getCellsMeta}. An entry is `null` when the cell is outside * the rendered viewport (virtualised grid). * * @returns {Array} */ getCellElements(): (HTMLTableCellElement | null)[][]; /** * Gets the merged cells configuration filtered to the current export range. * * Returned coordinates are 0-based data-array indices (matching the same coordinate * space as {@link DataProvider#getData}). Hidden rows/columns excluded from the export * are accounted for: the row/col offsets are compressed and the rowspan/colspan values * are reduced to cover only the exported cells within the merge span. * * Merges whose top-left cell is excluded, or that collapse to a single cell after * exclusion, are omitted from the result. * * @returns {Array} */ getMergeCells(): MergeCellDescriptor[]; /** * Gets widths (in pixels) for all visible columns in the export range. * * Returns values in the same column order as {@link DataProvider#getData}. * * @returns {Array} */ getColumnsWidths(): number[]; /** * Gets heights (in pixels) for all visible rows in the export range. * * Returns values in the same row order as {@link DataProvider#getData}. * * @returns {Array} */ getRowsHeights(): number[]; /** * Gets the number of frozen rows (`fixedRowsTop` setting). * * @returns {number} */ getFrozenRows(): number; /** * Gets the number of frozen columns (`fixedColumnsStart` setting). * * @returns {number} */ getFrozenColumns(): number; /** * Gets nested column header data from the NestedHeaders plugin for the current export range. * * Returns `null` when the NestedHeaders plugin is not enabled. Otherwise returns an array * of layers, where each layer is an array of `{ label, colspan, className }` objects * representing the visible column headers in that layer. Hidden columns (when * `exportHiddenColumns` is `false`) are excluded and their colspan contribution is removed * from spanning headers. * * @returns {Array[]|null} */ getNestedColumnHeaders(): { label: string; colspan: number; className: string; }[][] | null; /** * Appends a nested header entry for a single column when hidden columns are included in the export. * * @param {object} nestedHeadersPlugin The NestedHeaders plugin instance. * @param {number} layer The header layer index. * @param {number} col The current column index. * @param {number} endCol The last column index of the export range. * @param {Array} layerHeaders The array to push the header entry into. * @returns {number} The next column index to process. */ _appendNestedHeaderWithHidden(nestedHeadersPlugin: NestedHeadersPluginWithState, layer: number, col: number, endCol: number, layerHeaders: Array<{ label: string; colspan: number; className: string; }>): number; /** * Appends a nested header entry for a single column when hidden columns are excluded from the export. * * @param {object} nestedHeadersPlugin The NestedHeaders plugin instance. * @param {number} layer The header layer index. * @param {number} col The current column index. * @param {number} endCol The last column index of the export range. * @param {Array} layerHeaders The array to push the header entry into. * @returns {number} The next column index to process. */ _appendNestedHeaderWithoutHidden(nestedHeadersPlugin: NestedHeadersPluginWithSettings, layer: number, col: number, endCol: number, layerHeaders: Array<{ label: string; colspan: number; className: string; }>): number; /** * Gets `headerClassName` values for all visible column headers in the export range. * * Returns values in the same column order as {@link DataProvider#getColumnHeaders}. * An empty string is returned for columns that have no `headerClassName` configured. * * @returns {string[]} */ getColumnHeadersClassNames(): string[]; /** * Gets the layout direction of the Handsontable instance. * * @returns {'ltr'|'rtl'} */ getLayoutDirection(): "rtl" | "ltr"; /** * Gets column summary endpoint descriptors from the ColumnSummary plugin, translated * into the coordinate space of the exported data array. * * Returns an empty array when the plugin is absent or disabled. * Each descriptor contains: * * - `destRow` / `destCol` — 0-based indices into `getData()` identifying the destination cell. * - `type` — lowercase summary type (`'sum'`, `'min'`, `'max'`, `'count'`, `'average'`, `'custom'`). * - `sourceCol` — 0-based data-array column index of the source column. * - `sourceRanges` — array of `[startDataRow, endDataRow]` pairs (inclusive, 0-based) covering * the source rows after hidden-row exclusion and range clamping. * * @returns {Array} */ getColumnSummaries(): object[]; /** * Translates a single ColumnSummary endpoint into an export-coordinate summary descriptor. * * Converts physical row/column indices to 0-based data-array positions, builds the * compacted source-range array (merging consecutive indices), and excludes all * destination rows supplied in `allDestRows` to prevent circular Excel formula chains. * * Returns `null` when the endpoint falls outside the export range or produces no * valid source rows after filtering. * * @private * @param {object} endpoint ColumnSummary endpoint object from `getAllEndpoints()`. * @param {number} startRow First visual row of the export range. * @param {number} endRow Last visual row of the export range. * @param {number} startCol First visual column of the export range. * @param {number} endCol Last visual column of the export range. * @param {Set} allDestRows Data-array row indices of all summary destinations. * @returns {object|null} */ _transformEndpointToSummary(endpoint: SummaryEndpoint, startRow: number, endRow: number, startCol: number, endCol: number, allDestRows: Set): { destRow: number; destCol: number; type: string; sourceCol: number; sourceRanges: [number, number][]; } | null; /** * Counts the number of indices in `[start, end)` for which `isIncluded` returns `true`. * * Used by {@link DataProvider#_physicalRowToDataIndex} and * {@link DataProvider#_physicalColToDataIndex} to compute the 0-based data-array * position of a visual index by counting the visible indices that precede it. * * @private * @param {number} end Exclusive upper bound (the target visual index). * @param {number} start Inclusive lower bound of the export range. * @param {Function} isIncluded Returns `true` for indices that appear in the exported data. * @returns {number} */ _countVisibleBefore(end: number, start: number, isIncluded: (i: number) => boolean): number; /** * Converts a physical row index to a 0-based index into the exported data array. * * Returns `null` if the row is outside the export range, is hidden and hidden rows * are not being exported, or has no visual equivalent. * * @private * @param {number} physRow Physical row index. * @param {number} startRow First visual row of the export range. * @param {number} endRow Last visual row of the export range. * @returns {number|null} */ _physicalRowToDataIndex(physRow: number, startRow: number, endRow: number): number | null; /** * Converts a physical column index to a 0-based index into the exported data array. * * Returns `null` if the column is outside the export range, is hidden and hidden * columns are not being exported, or has no visual equivalent. * * @private * @param {number} physCol Physical column index. * @param {number} startCol First visual column of the export range. * @param {number} endCol Last visual column of the export range. * @returns {number|null} */ _physicalColToDataIndex(physCol: number, startCol: number, endCol: number): number | null; /** * Returns the natural (pre-hiding) width in pixels for a hidden column. * * `getColWidth()` returns 0 for hidden columns because the HiddenColumns plugin * overrides the `modifyColWidth` hook. This method reads the configured width * from column meta or the `colWidths` setting, bypassing that hook. * * @private * @param {number} colIndex Visual column index. * @returns {number} */ _getNaturalColWidth(colIndex: number): number; /** * Returns the natural (pre-hiding) height in pixels for a hidden row. * * `getRowHeight()` returns 0 for hidden rows because the HiddenRows plugin * overrides the `modifyRowHeight` hook. This method reads the configured height * directly from the `rowHeights` setting, bypassing that hook. * * @private * @param {number} rowIndex Visual row index. * @returns {number} */ _getNaturalRowHeight(rowIndex: number): number; /** * Check if row at specified row index is hidden. * * @private * @param {number} row Row index. * @returns {boolean} */ _isHiddenRow(row: number): boolean; /** * Check if column at specified column index is hidden. * * @private * @param {number} column Visual column index. * @returns {boolean} */ _isHiddenColumn(column: number): boolean; } export default DataProvider;