@@ -14,8 +14,6 @@ import { formulaEditor } from '../formula/formula-editor';
1414import { CellHighlightManager } from '../formula/cell-highlight-manager' ;
1515import type { TYPES } from '@visactor/vtable' ;
1616import { MenuManager } from '../managers/menu-manager' ;
17- import { exportMultipleVTablesToExcel , downloadExcel } from '@visactor/vtable-plugins' ;
18- import type { ExportVTableToExcelOptions } from '@visactor/vtable-plugins' ;
1917import { FormulaUIManager } from '../formula/formula-ui-manager' ;
2018import { SheetTabEventHandler } from './sheet-tab-event-handler' ;
2119
@@ -755,22 +753,23 @@ export default class VTableSheet {
755753 }
756754 }
757755 }
758- /** 导出所有sheet到一个Excel文件 */
759- async exportAllSheetsToExcel ( fileName ?: string , options ?: ExportVTableToExcelOptions ) : Promise < void > {
756+ exportAllSheetsToExcel ( ) : void {
757+ this . initAllSheetInstances ( ) ;
758+ const allDefines = this . sheetManager . getAllSheets ( ) ;
759+ const tables = allDefines . map ( def => {
760+ const inst = this . workSheetInstances . get ( def . sheetKey ) ! ;
761+ return { table : inst . tableInstance as any , name : def . sheetTitle || def . sheetKey } ;
762+ } ) ;
763+ ( this as any ) . _exportMutipleTablesToExcel ?.( tables ) ; //这个方法是在vtable-plugins中添加的,table-export插件在VTableSheet实例上添加了导出所有sheet到Excel的方法
764+ }
765+ initAllSheetInstances ( ) : void {
760766 const allDefines = this . sheetManager . getAllSheets ( ) ;
761- const activeKey = this . sheetManager . getActiveSheet ( ) ?. sheetKey ;
762767 allDefines . forEach ( def => {
763768 if ( ! this . workSheetInstances . has ( def . sheetKey ) ) {
764769 const instance = this . createWorkSheetInstance ( def ) ;
765770 this . workSheetInstances . set ( def . sheetKey , instance ) ;
766771 }
767772 } ) ;
768- const tables = allDefines . map ( def => {
769- const inst = this . workSheetInstances . get ( def . sheetKey ) ! ;
770- return { table : inst . tableInstance as any , name : def . sheetTitle || def . sheetKey } ;
771- } ) ;
772- const buffer = ( await exportMultipleVTablesToExcel ( tables , options ) ) as ArrayBuffer ;
773- await downloadExcel ( buffer , fileName || 'vtable-sheet-export' ) ;
774773 }
775774 /** 导入文件到当前sheet */
776775 async importFileToSheet ( ) : Promise < ImportResult | void > {
0 commit comments