大数据Excel导出方案

static void Main(string[] args) {
    Excel.Application app = new Excel.Application();
 
    Excel._Workbook result = app.Workbooks.Add();
    Excel._Workbook wb1 = app.Workbooks.Open(Path.GetFullPath("./Sources/Source1.xlsx"));
    Excel._Workbook wb2 = app.Workbooks.Open(Path.GetFullPath("./Sources/Source2.xlsx"));
 
    foreach (Excel._Worksheet each in wb1.Sheets) {
        each.Copy(result.Worksheets[1]);
    }
 
    foreach (Excel._Worksheet each in wb2.Sheets) {
        each.Copy(result.Worksheets[1]);
    }
 
    result.SaveAs(@"c:\result.xlsx");
 
    Console.WriteLine("press any key to exit.");
    Console.ReadLine();
 
    wb1.Close();
    wb2.Close();
    app.Quit();
}
 

摘抄自讨论帖:https://bbs.csdn.net/topics/380167794/

posted @ 2018-04-26 16:19  Bill he  阅读(350)  评论(1编辑  收藏  举报