/** * **Optional SheetJS-backed Excel exporter.** * * This adapter is the officially-supported way to produce real `.xlsx` * workbooks. It is deliberately **not** referenced by the core barrel * (`src/index.ts`) and is published on its own entry point, and — unlike the * import-side SheetJS adapter — it never so much as names `'xlsx'` in an * `import()`. The host passes the module in: * * ```ts * import * as XLSX from 'xlsx'; * import { registerExporter } from 'photon-grid-core'; * import { createExcelExporter } from 'photon-grid-core/export/excel'; * * registerExporter('excel', createExcelExporter(XLSX)); * await grid.api.export('excel', { fileName: 'employees.xlsx' }); * ``` * * That inversion is what keeps Photon Grid Core at zero runtime dependencies: * this file contains only the structural types below, so nothing about `xlsx` * can be bundled by anyone who does not import it themselves. * * The workbook it writes uses **native cell types** — numbers stay numbers, * booleans stay booleans, dates stay dates — so the result can be summed, * sorted and filtered in Excel without re-parsing text. Column visibility, * column order and the export's row scope all come from the shared * {@link PreparedExportData}, so a workbook always matches the CSV of the same * grid. * * @packageDocumentation */ import type { ExcelExportOptions, ExportColumn, GridExporter } from '../export.types'; /** A SheetJS worksheet — an opaque handle as far as this adapter is concerned. */ export interface SheetJsWorksheet { '!cols'?: Array<{ wch?: number; }>; '!freeze'?: string; [key: string]: unknown; } /** A SheetJS workbook. */ export interface SheetJsWorkbook { SheetNames: string[]; Sheets: Record; [key: string]: unknown; } /** The `XLSX.utils` members this adapter calls. */ export interface SheetJsUtils { book_new(): SheetJsWorkbook; book_append_sheet(workbook: SheetJsWorkbook, sheet: SheetJsWorksheet, name?: string): void; aoa_to_sheet(data: unknown[][], opts?: { cellDates?: boolean; }): SheetJsWorksheet; } /** The `xlsx` module surface this adapter calls. */ export interface SheetJsModule { readonly utils: SheetJsUtils; write(workbook: SheetJsWorkbook, opts: { bookType?: string; type?: string; cellDates?: boolean; }): unknown; } /** * Builds an Excel {@link GridExporter} bound to a host-supplied SheetJS module. * * @param xlsx - The `xlsx` module (`import * as XLSX from 'xlsx'`), or anything * structurally compatible with {@link SheetJsModule}. * @returns An exporter ready for `registerExporter('excel', …)`. * @throws {TypeError} When `xlsx` is missing or is not the SheetJS module — a * clear failure at registration beats an opaque one at export time. */ export declare function createExcelExporter(xlsx: SheetJsModule): GridExporter; /** Re-exported so a host writing its own adapter can reuse the column shape. */ export type { ExportColumn }; //# sourceMappingURL=excel-exporter.d.ts.map