Click here to Skip to main content
12,633,519 members (31,177 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP .NET
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 9-Apr-12 18:57pm
Tisfy630
Updated 9-Apr-12 20:44pm
Mehdi Gholam329.2K
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

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;
  Permalink  
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.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

This looks like what you are looking for without having to copy tables:

http://stackoverflow.com/questions/7157677/copying-worksheets-between-workbooks-excel-interop[^]
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161208.2 | Last Updated 7 May 2014
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100