tags:

views:

3400

answers:

2

I have a database which contains 5 tables. Each table contains 24 rows and each row contains 4 columns.

I want to display these records in Excel sheet. The heading of each table is the name of the table, but I am unable to merge the columns for heading.

Please help me.

+2  A: 

Using the Interop you get a range of cells and call the .Merge() method on that range.

eWSheet.Range(eWSheet.Cells(1, 1), eWSheet.Cells(4, 1)).Merge()
C. Ross
A: 

Code Snippet

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private Excel.Application excelApp = null;

private void button1_Click(object sender, EventArgs e)

{

excelApp.get_Range("A1:A360,B1:E1", Type.Missing).Merge(Type.Missing);

}

private void Form1_Load(object sender, EventArgs e)

{

excelApp = Marshal.GetActiveObject("Excel.Application") as Excel.Application ;

}

}

Thanks