We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Horizontal & Veritcal Merging of Cells

Does the Aspose Excel Component allow merging of cells in both horizontal and vertical direction? I saw the syntax for “Merge” function of Cells object in Aspose.Excel API Reference section. What do the integers 5,4,2,2 indicate in “cells.Merge(5, 4, 2, 2)”?
Thanks.

Yes, Aspose.Excel supports merging of cells in both horizontal and vertical direction.

cell.Merge(5,4,2,2) means that you want to merge cell E6 to F7 as one cell. The first two parameters indicates the first cell E6 (row index and column index are zero based). The last two parameters indicates the number of rows and columns to be merged following the start cell.

@klakshmi,
Aspose.Cells has replaced Aspose.Excel which is no more available now. This new product Aspose.Cells is much better in performance and range of features which are provided. It supports all the latest versions of MS Excel. Merging cells and ranges is also supported in this new product as demonstrated below:

// Create a Workbook.
Workbook wbk = new Workbook();

// Create a Worksheet and get the first sheet.
Worksheet worksheet = wbk.Worksheets[0];

// Create a Cells object ot fetch all the cells.
Cells cells = worksheet.Cells;

// Merge some Cells (C6:E7) into a single C6 Cell.
cells.Merge(5, 2, 2, 3);

// Input data into C6 Cell.
worksheet.Cells[5, 2].PutValue("This is my value");

// Create a Style object to fetch the Style of C6 Cell.
Style style = worksheet.Cells[5, 2].GetStyle();

// Create a Font object
Font font = style.Font;

// Set the name.
font.Name = "Times New Roman";

// Set the font size.
font.Size = 18;

// Set the font color
font.Color = System.Drawing.Color.Blue;

// Bold the text
font.IsBold = true;

// Make it italic
font.IsItalic = true;

// Set the backgrond color of C6 Cell to Red
style.ForegroundColor = System.Drawing.Color.Red;
style.Pattern = BackgroundType.Solid;

// Apply the Style to C6 Cell.
cells[5, 2].SetStyle(style);

// Save the Workbook.
wbk.Save(dataDir + "mergingcells.out.xls");

You may visit the following links for more details on this feature:
Merging and Unmerging Cells
Merge or Unmerge Range of Cells

Here is link to free trial version of this new product:
Aspose.Cells for .NET (Latest Version)

A runnable solution can be downloaded for testing the product features here.