import type { ISheetChartInfo } from '@univerjs-pro/sheets-chart'; import type { FWorksheet } from '@univerjs/sheets/facade'; import { FWorkbook } from '@univerjs/sheets/facade'; /** Options for creating a Chart Sheet through existing chart commands. */ export interface IInsertChartSheetOptions { /** Unique worksheet name; omitted names use the existing localized default. */ name?: string; /** Zero-based final tab position; omitted positions follow the existing conversion command. */ index?: number; } /** @ignore */ export interface IFWorkbookChartSheetMixin { /** * Creates a Chart Sheet and its primary chart from detached Chart information. * The source cells remain on their Grid worksheets. Successful creation shares one undo entry; * a later failure may retain already committed state and its history instead of rolling back the whole call. * * @param {ISheetChartInfo} info Chart information with explicit source Grid worksheets in this workbook. * @param {IInsertChartSheetOptions} [options] Optional name and zero-based final tab index. * @param {string} [options.name] A unique, valid sheet name; omitted names use the localized default. * @param {number} [options.index] Final tab position from zero through the current sheet count; * omitted positions follow the existing chart conversion behavior. * @returns {Promise} The new Chart Sheet containing its primary chart. * @throws {CustomCommandExecutionError} If the source, options, permissions, or a creation command is rejected. * @example * ```ts * import '@univerjs-pro/sheets-chart/facade'; * * // Data is an existing Grid worksheet with chart data in A1:B4. * const fWorkbook = univerAPI.getActiveWorkbook(); * const fDataSheet = fWorkbook?.getSheetByName('Data'); * if (fWorkbook && fDataSheet) { * const chartInfo = fDataSheet * .newChart(univerAPI.Enum.ChartTypeString.Column) * .setSource({ sheetId: fDataSheet.getSheetId(), range: 'A1:B4' }) * .build(); * const fChartSheet = await fWorkbook.insertChartSheet(chartInfo, { * name: 'Sales Report', * index: 0, * }); * * // Creation also inserts the primary chart; the source cells stay on Data. * console.log(fChartSheet.getPrimaryChart()?.isPrimary()); // true * } * ``` */ insertChartSheet(info: ISheetChartInfo, options?: IInsertChartSheetOptions): Promise; } /** @ignore */ export declare class FWorkbookChartSheetMixin extends FWorkbook implements IFWorkbookChartSheetMixin { insertChartSheet(info: ISheetChartInfo, options?: IInsertChartSheetOptions): Promise; private _validateChartSheetOptions; } declare module '@univerjs/sheets/facade' { interface FWorkbook extends IFWorkbookChartSheetMixin { } }