I am trying to Merge column A cells in one of my worksheet.
I used following function:
worksheet.Cells.Merge(5, 0,2, *)
what I should put instead of * if I want to merge A5 and A6 cells. If I put 0 instead of * then it merges entire row. If I put 1 instead of * , then A and B both column cells are merged.
Please help.
Hi,
Thanks for considering Aspose.
Well, Cells.Merge() has four parameters. The third parameter refers to refers to number of rows to be mereged (one-based), you will provide atleast 1 or greater value. The fourth parameter refers to number of columns to be merged (also one-based) and you will provide here atleast 1 or greater value. So please change your code to: worksheet.Cells.Merge(4, 0, 2, 1) if you want to merge A5:A6 cells.
I use the following code and the output is fine, kindly check the attached file:
[C#]
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
Cells cells = sheet.Cells;
//Merging A5:A6 cells.
cells.Merge(4,0,2,1);
workbook.Save("d:\\test\\tstmergingcells.xls");
[VB]
Dim workbook As Workbook = New Workbook()
Dim sheet As Worksheet = workbook.Worksheets(0)
Dim cells As Cells = sheet.Cells
'Merging A5:A6 cells.
cells.Merge(4,0,2,1)
workbook.Save("d:\test\tstmergingcells.xls")
For Reference, Please check our Wiki document: Merging Cells
Thank you.