/** * Excel-to-Word Bridge * * Converts an Excel Workbook into a DocxDocument model. * This is the ONLY file in the Word module that imports from @excel. * * @example * ```typescript * import { Workbook } from "excelts"; * import { excelToDocx } from "excelts/word/excel"; * * const wb = new Workbook(); * await wb.xlsx.load(buffer); * const doc = excelToDocx(wb); * ``` */ import type { AddChartExOptions, ChartExModel, ChartExType } from "../../excel/chart/chart-ex-types.js"; import type { ChartModel } from "../../excel/chart/types.js"; import type { Workbook } from "../../excel/workbook.browser.js"; import type { Chart, DocxDocument } from "../types.js"; /** Options for Excel → DOCX conversion. */ export interface ExcelToDocxOptions { /** Which sheets to include (by name or 0-based index). Default: all visible sheets. */ readonly sheets?: readonly (string | number)[]; /** Include sheet name as heading before each table. Default: true. */ readonly includeSheetHeadings?: boolean; /** Heading level for sheet names (1-6). Default: 2. */ readonly sheetHeadingLevel?: number; /** Include a title page with workbook metadata. Default: false. */ readonly includeTitlePage?: boolean; /** Maximum columns to include per sheet (avoids excessively wide tables). Default: 50. */ readonly maxColumns?: number; /** Maximum rows per sheet to include. Default: 10000. */ readonly maxRows?: number; /** Preserve cell formatting (bold, italic, colors, etc.). Default: true. */ readonly preserveFormatting?: boolean; /** Include cell borders in table. Default: true. */ readonly includeBorders?: boolean; } /** * Convert an Excel Workbook to a DocxDocument model. * * Creates a Word document with tables representing each worksheet's data. * Preserves cell formatting (fonts, colors, alignment) as run/paragraph properties. * * @param workbook - The Excel Workbook to convert. * @param options - Conversion options. * @returns A DocxDocument model ready for packaging, PDF conversion, or Markdown output. */ export declare function excelToDocx(workbook: Workbook, options?: ExcelToDocxOptions): DocxDocument; export type { AddChartExOptions, ChartExModel, ChartExType, ChartModel }; /** Options for creating a ChartEx in a Word document. */ export interface WordChartExOptions { /** ChartEx type (sunburst, treemap, waterfall, funnel, histogram, pareto, boxWhisker, regionMap). */ readonly type: ChartExType; /** Series data (with literal categories/values for Word context). */ readonly series: readonly { readonly name: string; readonly categories?: readonly string[]; readonly values: readonly number[]; }[]; /** Chart title. */ readonly title?: string | null; /** Show legend. Default: true. */ readonly showLegend?: boolean; /** Legend position. */ readonly legendPosition?: "b" | "l" | "r" | "t" | "tr"; } /** * Build a ChartEx XML part for embedding in a Word document. * * This bridges the Excel ChartEx renderer into the Word module, * generating a complete `cx:chartSpace` XML string from high-level options. * * @param options - Chart configuration. * @returns The complete ChartEx XML string for the chart part. */ export declare function buildWordChartExXml(options: WordChartExOptions): string; /** * Render a Word Chart to SVG string for HTML embedding. * * Bridges Word's Chart definition to Excel's chart renderer by constructing * a ChartModel with literal (inline) data and delegating to renderChartSvg. * * @param chart - The Word Chart definition. * @returns SVG markup string. */ export declare function renderWordChartSvg(chart: Chart): string; /** * Generate an embedded xlsx for chart data. * Uses the full Excel xlsx writer for maximum compatibility. * * The resulting xlsx contains a single Sheet1 with: * - Row 1: header (empty cell A1, then series names in B1, C1, ...) * - Row 2+: category in column A, values in subsequent columns * * @param series - Chart data series * @returns xlsx file as Uint8Array */ export declare function generateChartEmbeddedXlsx(series: readonly { name: string; categories: readonly string[]; values: readonly number[]; }[]): Promise; /** * Convert a Word Chart definition to an Excel ChartModel. * This is the single source of truth for Word→Excel chart mapping. * * Used by: * - `renderWordChartSvg` (SVG rendering for HTML embedding) * - `createWordChartPdfRenderer` in `@pdf/excel-bridge` (PDF vector rendering) * * @param chart - The Word Chart definition. * @returns A fully constructed ChartModel suitable for Excel's chart renderer. */ export declare function wordChartToChartModel(chart: Chart): ChartModel; /** * Extract tables from a Word document and convert them to Excel worksheet data. * Each table becomes a 2D array of cell values. * * @param doc - The DOCX document model. * @returns Array of table data objects, each with a name and 2D data array. */ export declare function extractTablesToExcel(doc: DocxDocument): { name: string; data: (string | number | null)[][]; }[];