Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Thu Jan 25, 2018 8:25 am

Hi there

I have the following document:

word_dok.PNG


Then i run the following code:
Code: Select all
Document a = new Document(@"C:\tmp\TestDocument.docx");

Table t = a.Sections.FirstItem.ChildObjects.OfType<Body>().First().ChildObjects.OfType<Table>().First();

t.ApplyVerticalMerge(0, 0, 1);

a.SaveToFile(@"C:\tmp\TestDocument1.docx");


The result ist this:
word_dok_result.PNG


I think this is a bug. Can you confirm and fix this?

Thanks & best regards

storztools
 
Posts: 5
Joined: Fri Aug 04, 2017 11:42 am

Thu Jan 25, 2018 9:46 am

Hi,

Thanks for your inquiry.
To some extent, it is not a bug. This issue occurs because we have made it as a standard in our mechanism. In case that other customer didn't want the content in the row that is going to be merged, we didn't add them to the document. If you would like to get the content displayed, you need to obtain the content first and add them to the related position manually. Please refer to the code below.

Code: Select all
Document document = new Document();
document.LoadFromFile(word_file_open_dialog.FileName);
Table t = document.Sections.FirstItem.ChildObjects.OfType<Body>().First().ChildObjects.OfType<Table>().First();

t.ApplyVerticalMerge(0, 0, 1);

//Get all the content in the second row
List<DocumentObject> list = new List<DocumentObject>();
foreach(DocumentObject cell in t.Rows[1].Cells)
{
    foreach (DocumentObject cellcontent in cell.ChildObjects)
    {
        list.Add(cellcontent);
    }
}

//Add the content to the first row
for(int i=0;i<list.Count;i++)
{
    t.Rows[0].Cells[0].ChildObjects.Add(list[i]);
}

document.SaveToFile(@"TestDocument1.docx");


Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Mon Jan 29, 2018 7:49 am

Hi storztools,

Greetings from e-iceblue!
Has your issue been resolved? Your feedback would be greatly appreciated.

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Thu Feb 01, 2018 6:55 am

Hi and thanks for the workaround. I think its a little bit strange because its not the same behavior as in microsoft word but i can live with that workaround.

Thanks and best regards.

storztools
 
Posts: 5
Joined: Fri Aug 04, 2017 11:42 am

Thu Feb 01, 2018 8:14 am

Hello,

Thanks for your valuable feedback.
Please feel free to contact us if you need any help.

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Return to Spire.Doc