VB.NET 如何将某个Excel的工作表中复制到另一个的Excel中的工作表中https://bbs.csdn.net/topics/392861034

参考http://share.freesion.com/306372/可以实现直接拷贝指定表VB.NET 如何将某个Excel的工作表中复制到另一个的Excel中的工作表中https://bbs.csdn.net/topics/392861034_第1张图片

 Private Sub Excel复制工作簿()
        Dim myExcelApp As New Microsoft.Office.Interop.Excel.Application

        myExcelApp.Workbooks.Open(System.Environment.CurrentDirectory + "\\测试用例.xlsx", Type.Missing)
        myExcelApp.Workbooks.Open(System.Environment.CurrentDirectory + "\\复制用例.xlsx", Type.Missing)

        Dim worksheet1 As Microsoft.Office.Interop.Excel.Worksheet = CType(myExcelApp.Workbooks(1).Worksheets(1),  _
                                                                            Microsoft.Office.Interop.Excel.Worksheet)
        Dim worksheet2 As Microsoft.Office.Interop.Excel.Worksheet = CType(myExcelApp.Workbooks(2).Worksheets(1),  _
                                                                            Microsoft.Office.Interop.Excel.Worksheet)
        worksheet1.Copy(After:=worksheet2)

        myExcelApp.Workbooks(2).Save()
        myExcelApp.Quit()
        myExcelApp = Nothing

    End Sub

你可能感兴趣的:(.net,excel)