Free Support Forum -

How to put value in merged cells

I am trying to put value to the merged cells. how to do that


Thanks for considering Aspose,

Well, When you merge the cells, it actually combines the cells to a single cell and becomes the top left cell in the merging range of cells. So, If you want to put value in the merging range of cells, you will put into that particular cell (top left cell).

Please find the sample code:

Aspose.Cells.Workbook wbk=new Aspose.Cells.Workbook();


Aspose.Cells.Worksheet worksheet = wbk.Worksheets[0];

Aspose.Cells.Cells cells = worksheet.Cells;

// merges the cells in the range (C6:E7)


// C6 is the top left cell so you will put value to it.

worksheet.Cells[5,2].PutValue("This is my value");

Aspose.Cells.Style style = worksheet.Cells[5,2].Style;

style.Font.Size = 18;

style.Font.Color = Color.Blue;

style.ForegroundColor = Color.Red;

style.Pattern = BackgroundType.Solid;

cells[5,2].Style = style;



Amjad Sahi

Aspose Nanjing Team