Excel跨表复制
Excel.Application excelApplication = null;
Excel.Workbooks excelWorkBooks = null;
Excel.Workbook excelWorkbook = null;
Excel.Workbook excelWorkbook1 = null;
Excel.Worksheet excelWorkSheet = null;
Excel.Worksheet excelWorkSheet1 = null;
Excel.Range range = null;
Excel.Range range1 = null;
public void print(string lujin1,string,lujin2){
excelApplication = new Excel.ApplicationClass();
excelWorkBooks = excelApplication.Workbooks;
excelWorkbook =((Excel.Workbook)excelWorkBooks.open(lujin1,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,));
ExcelWorkBook.Worksheets.Add();//添加空表
excelWorkSheet = excelWorkBook.Worksheet[1];//获取空表
range = excelWorkSheet.get_Range("A1:F40");//需要粘贴到的对应位置
excelWorkbook1 =((Excel.Workbook)excelWorkBooks.open(lujin2,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,));//打开需复制的文档
excelWorkSheet1 = excelWorkBook.Worksheet[1];//得到工作表
range1 = excelWorkSheet1.get_Range("A1:F40");//获取需要复制的值
range.PasteSpecial(Microsoft.Office.Interop.Excel.XlPasteType.xlPasteAll,Microsoft.Office.Interop.Excel.XlPasteSpecialOperation.XlPasteSpecialOperationNone,Missing.Value,Missing.Value);//带格式的粘贴
}