简体   繁体   中英

last row is not merged in ms word table using aspose word for java

i have created a table in ms word by aspose.word using node. Now i need table in which 2nd column will be merged except first row I got the merge column, but first and last row is not merging. First row is okay, because it was coded for that. But I cannot find out why last row is not merged.

I have not enough reputation to attach image. So, I have to describe details of my output

Here is my code :

Document doc=new Document();


Table table = new Table(doc);
// Add the table to the document.

doc.getFirstSection().getBody().appendChild(table);//add table



Row row[]= new Row[4];Cell cell[] = new Cell[3];


for (int i = 0; i < row.length; i++) {

row[i]=new Row(doc);table.appendChild(row[i]); 

 table.autoFit(AutoFitBehavior.AUTO_FIT_TO_WINDOW);//if I set this here last row not   //merge


       for (int j = 0; j < cell.length; j++) {

    cell[j]=new Cell(doc);
    row[i].appendChild(cell[j].deepClone(false));//cell creation
   // but in this position table.autoFit(AutoFitBehavior.AUTO_FIT_TO_WINDOW) create //no problem


    row[i].getLastCell().appendChild(new Paragraph(doc));


    if(row[i]==table.getFirstRow())
    {

    }

    else
    {
        if(j==1)
        {
            if(i==1)
            {
                row[i].getCells().get(j).getCellFormat().setVerticalMerge(CellMerge.FIRST); 

            }
            else
            {


                row[i].getCells().get(j).getCellFormat().setVerticalMerge(CellMerge.PREVIOUS);


            }   
        }

    }


}

}   

I am getting the following output by running your code. Kindly make sure that you are using the latest version of Aspose.Words for Java . If you are having same issue with latest version too, please share your environment details so that I can reproduce it at my side. 产量 Download the latest version by visiting Aspose.Words for Java or directly download the Jar file from our Maven repository.

Disclosure: I am a developer at Aspose.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM