Q:

C#- Microsoft. Office. Interop. Excel copy all rows in excel to another sheet

I have 3-4 excel files in a directory, each excel workbook contains 1 sheet.  The structure of each sheet are identical.  I want to consolidate all the sheets into one sheet.  I am using Microsoft. Office. Interop. Excel package in VS 2008.  How do I copy all the rows in one worksheet and append at the end of another worksheet?  I am new to C# so my question may be improper.  Thanks for help. 

A:

That's quite a big question, I'm not sure which specific bits you need help on.  I can get the ball rolling with this code
using Microsoft. Office. Interop. Excel;
using System;
using System. Collections. Generic;
using System. Linq;
using System. Text;
using System. Threading. Tasks;

namespace ConsoleApplication3
{ 
class Program
{
    static void Main(string[] args)
    {
        Application excel = new Application();
        Workbook wb1 = excel. Workbooks. Open("c:\\temp\\me.xlsx");
        Workbook wb2 = excel. Workbooks. Open("c:\\temp\\you.xlsx");
        Range src = wb1.Sheets["Sheet1"].Range("A1:B3");
        Range dest = wb2.Sheets["Sheet1"].Range("A10");

        src. Copy(dest);
        wb2.Save();
        wb1.Close();
        wb2.Close();
        excel. Quit();
    }
}
}

will copy some cells from 'me.xlsx' to 'you.xlsx' (note this is a newer version of VS than you're using)
Does this help?