Free Support Forum -

Problem with Cell Merge


I’m new to using the Excel component. I’m trying to do some formatting in my header like this:

P | A

Where Wednesday and 1/1/2003 would span 2 columns (so that P and A would each appear beneath the joined columns). This seemed like an opporunity to use Merge.

I tried:

sheet.Cells.Merge(1, col, 0, 1);

Where col is the column i’m currently on (I have to dynamically build the columns going across for X # of dates). But what results is a column that merged ALL of its rows, (so L1 is the only cell in column L for example).

I expected it to:

At Row 1
At Column "col"
Merge 0 rows down
Merge 1 column over

Am I misunderstanding its intended behavior?

Thank you!


Thanks for your consideration.

The number of merged rows and columns is one based. So please try:

sheet.Cells.Merge(1, col, 1, 2);