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: esult.xlsx"); Console.WriteLine("press any key to exit."); Console.ReadLine(); wb1.Close(); wb2.Close(); app.Quit(); }
摘抄自讨论帖:https://bbs.csdn.net/topics/380167794/