Good Morning Everyone,

May i know how to extract all data from a excel file and copy the data all over to another excel file?

Example from Excel A, we have data

EmployeeID Name Department

 1111           John          MIS

I want to copy the data over to Excel B... may i know how to do that using

Please assist me!

I'm not going to give you any code but a hint. From there you can start coding.

I'm assuming you know how to add reference on Microsoft Excel and Import Microsoft.Office.Excel.

-> Declare a variable as and Excel.Application
-> Declare workbookA and workbookB as Excel.Workbooks (data will be copied from workbookA to workbookB, workbook1 will have the original data and workbook2 is a blank workbook)
-> create new workbook for workbookB and Open workbookA
-> copy data from columnA to column C of workbookA, activate workbookB and paste data. Do until row of workbookA is empty.

Please google for more information. Hope this helps!

hi... the problem is solved!


Glad to see you already solved your problem.
Here I'd provide code snippet in VB.NET for copying worksheet in Excel, hope it can be helpful.(P.S. You have to add .NET Excel.dll as a reference in your project before using the below code)

Imports Spire.Xls

Namespace Copy_Worksheet

    Class Program

        Private Shared Sub Main(ByVal args() As String)
            Dim workbook As Workbook = New Workbook
            workbook.LoadFromFile("..\copy worksheets.xls")
            Dim worksheet As Worksheet = workbook.Worksheets(0)
            'add worksheets and name them
            workbook.Worksheets.Add("copied sheet1")
            workbook.Worksheets.Add("copied sheet2")
            'copy worksheet to the new added worksheets
            workbook.SaveToFile("..\copy worksheets.xls")
            System.Diagnostics.Process.Start("..\copy worksheets.xls")
        End Sub
    End Class
End Namespace