Click here to Skip to main content
14,699,089 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I am developing an App via c#, and want to merge excel files which actually talks about one thing. I am using Microsoft Excel 14.0 Object Library to open my excel files: codes are as following;
using Excel = Microsoft.Office.Interop.Excel; 

handle event:
Excel.Application xlApp ;
           Excel.Workbook xlWorkBook ;
           Excel.Worksheet xlWorkSheet ;
           object misValue = System.Reflection.Missing.Value;

           xlApp = new Excel.Application();
           xlWorkBook = xlApp.Workbooks.Open("D:\\**.xlsx", 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
           xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);

But for How Merge Excel, I came with no solution or codes. Please share some ideas or codes with me. Thanks very much.
Posted
Updated 9-Apr-12 20:44pm
v2

Try this please:

Excel.Application xl = new Excel.ApplicationClass();

Excel.Workbook wb = xl.Workbooks.Add(Excel.XlWBATemplate.xlWBATWorkshe et);

Excel.Worksheet ws = (Excel.Worksheet)wb.ActiveSheet;

ws.Cells[1,1] = "Testing";

Excel.Range range = ws.get_Range(ws.Cells[1,1],ws.Cells[1,2]);

range.Merge(true);

range.Interior.ColorIndex =36;

xl.Visible =true;
   
v2
Comments
anukolli 20-Feb-15 6:52am
   
But for How Merge Excel, I came with no solution or codes. Please share some ideas or codes with me.
This looks like what you are looking for without having to copy tables:

http://stackoverflow.com/questions/7157677/copying-worksheets-between-workbooks-excel-interop[^]
   
Comments
Tisfy 10-Apr-12 4:53am
   
Thanks for kind help. Clifford.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900