将两个excel文件合并到一个新的Excel文件中

1、首先需要安装autoit,这个网上应该有很多

2、创建两个文件,里边写一些东西

3、脚本编写

#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.5 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <Excel.au3> #include <MsgBoxConstants.au3> #include-once #include "Array.au3" #include "ExcelConstants.au3" Local $oExcel = _Excel_Open() Local $filePath = $CmdLine[1] Local $oWorkBook = _Excel_BookOpen($oExcel,$filePath) Local $targetPath = $CmdLine[2] Local $oWorkBook1 = _Excel_BookOpen($oExcel,$targetPath) Local $oWorkBook2 = _Excel_BookNew($oExcel,Default) Local $oSheetList = _Excel_SheetList($oWorkBook) Dim $i For $i=1 To UBound($oSheetList) Local $oSheet = _Excel_SheetCopyMove($oWorkbook,$i,$oWorkBook2,$i,False,Default) $oSheet.Name = "a" & $i Next Local $oSheetList1 = _Excel_SheetList($oWorkBook1) ;_Excel_BookSaveAs($oWorkBook2,"d:/merge.xls") Dim $j For $j=1 To UBound($oSheetList1) $toIndex = UBound($oSheetList) + $j Local $oSheet1 = _Excel_SheetCopyMove($oWorkbook1,$j,$oWorkBook2,$toIndex,False,Default) $oSheet1.Name = "a" & $toIndex Next _Excel_BookSaveAs($oWorkBook2,"d:/merge.xls") _Excel_SheetDelete($oWorkBook2,1); _Excel_Close($oExcel) MsgBox(64,"提示","执行完成")

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zggsds.html