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

Free Support Forum - aspose.com

Cannot merge vertically on second column

Hi,

In this below code i can merge vertically on first column
In second column, i can't merge because its affects the first column
builder.InsertCell();
builder.CellFormat.HorizontalMerge = CellMerge.First;
builder.Write("Text in merged cells.");

builder.InsertCell();
// This cell is merged to the previous and should be empty.
builder.CellFormat.HorizontalMerge = CellMerge.Previous;
builder.EndRow();

builder.InsertCell();
builder.CellFormat.HorizontalMerge = CellMerge.None;
builder.Write(“Text in one cell.”);

builder.InsertCell();
builder.Write(“Text in another cell.”);
builder.EndRow();
builder.EndTable();

<pre class=“code” style=“margin-top: 0.5em; margin-bottom: 0.5em; font-stretch: normal; font-size: 11.2px; line-height: normal; font-family: monospace, “Courier New”, Courier; color: rgb(0, 0, 102); background-color: rgb(238, 238, 238); padding: 4px 6px;”>
<pre class=“code” style=“margin-top: 0.5em; margin-bottom: 0.5em; font-stretch: normal; font-size: 11.2px; line-height: normal; font-family: monospace, “Courier New”, Courier; color: rgb(0, 0, 102); background-color: rgb(238, 238, 238); padding: 4px 6px;”>
<pre class=“code” style=“margin-top: 0.5em; margin-bottom: 0.5em; font-stretch: normal; font-size: 11.2px; line-height: normal; font-family: monospace, “Courier New”, Courier; color: rgb(0, 0, 102); background-color: rgb(238, 238, 238); padding: 4px 6px;”>Pls tell me the solution<pre class=“code” style=“margin-top: 0.5em; margin-bottom: 0.5em; font-stretch: normal; font-size: 11.2px; line-height: normal; font-family: monospace, “Courier New”, Courier; color: rgb(0, 0, 102); background-color: rgb(238, 238, 238); padding: 4px 6px;”>
<pre class=“code” style=“margin-top: 0.5em; margin-bottom: 0.5em; font-stretch: normal; font-size: 11.2px; line-height: normal; font-family: monospace, “Courier New”, Courier; color: rgb(0, 0, 102); background-color: rgb(238, 238, 238); padding: 4px 6px;”>Thanks,<pre class=“code” style=“margin-top: 0.5em; margin-bottom: 0.5em; font-stretch: normal; font-size: 11.2px; line-height: normal; font-family: monospace, “Courier New”, Courier; color: rgb(0, 0, 102); background-color: rgb(238, 238, 238); padding: 4px 6px;”>Narendran
Hi Narendran,

Thanks for your inquiry. If you want to merge cells vertically, please use CellFormat.VerticalMerge property as shown below.

If you still face problem, please share your expected output document here for our reference. We will then provide you more information about your query along with code.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

builder.InsertCell();

builder.CellFormat.VerticalMerge = CellMerge.First;

builder.Write("Text in merged cells.");

builder.InsertCell();

builder.CellFormat.VerticalMerge = CellMerge.None;

builder.Write("Text in one cell");

builder.EndRow();

builder.InsertCell();

// This cell is vertically merged to the cell above and should be empty.

builder.CellFormat.VerticalMerge = CellMerge.Previous;

builder.InsertCell();

builder.CellFormat.VerticalMerge = CellMerge.None;

builder.Write("Text in another cell");

builder.EndRow();

builder.EndTable();

doc.Save(MyDir + "Out.docx");

Hi,


Document doc = new Document();<o:p></o:p>

DocumentBuilder builder = new DocumentBuilder(doc);<o:p></o:p>

<o:p> </o:p>

builder.InsertCell();<o:p></o:p>

builder.CellFormat.VerticalMerge = CellMerge.First;<o:p></o:p>

builder.Write(“Text in merged cells.”);<o:p></o:p>

<o:p> </o:p>

builder.InsertCell();<o:p></o:p>

builder.CellFormat.VerticalMerge = CellMerge.None;<o:p></o:p>

builder.Write(“Text in one cell”);<o:p></o:p>

builder.EndRow();<o:p></o:p>

<o:p> </o:p>

builder.InsertCell();<o:p></o:p>

// This cell is vertically merged to the cell above and should be empty.<o:p></o:p>

builder.CellFormat.VerticalMerge = CellMerge.Previous;<o:p></o:p>

<o:p> </o:p>

builder.InsertCell();<o:p></o:p>

builder.CellFormat.VerticalMerge = CellMerge.None;<o:p></o:p>

builder.Write(“Text in another cell”);<o:p></o:p>

builder.EndRow();<o:p></o:p>

builder.EndTable();



I have attached my actual output and my expected output, In the date column the above code works fine, but in the group cloumn it not working, kindly help.
Hi Narendran,

Thanks for sharing the documents. In case you are using older version of Aspose.Words, we suggest you please use latest version of Aspose.Words for .NET 17.3.0. Hope this helps you.

If you still face problem, please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing. We will investigate the issue on our side and provide you more information.