java - 最后一行未使用 aspose word for java 合并到 ms word 表中

标签 java merge ms-word aspose.words

我已经通过 aspose.word 使用节点在 ms word 中创建了一个表。现在我需要一个表格,其中第二列将被合并(第一行除外) 我得到了合并列,但第一行和最后一行没有合并。第一行没问题,因为它是为此编码的。但我无法找出为什么最后一行没有合并。

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

这是我的代码:

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);


            }   
        }

    }


}

}   

最佳答案

通过运行您的代码,我得到以下输出。请确保您使用的是最新版本的Aspose.Words for Java 。如果您在最新版本中也遇到同样的问题,请分享您的环境详细信息,以便我可以在我身边重现它。 Output 访问Aspose.Words for Java下载最新版本或直接下载Jar file来 self 们的 Maven 存储库。

披露:我是 Aspose 的开发人员。

关于java - 最后一行未使用 aspose word for java 合并到 ms word 表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25710251/

相关文章:

java - 从文本文件 : not all data stored, 创建嵌套 HashMap 可能会被覆盖

Java为什么日历afieldset是假的?

mysql - 当列应该变得唯一时合并相关数据

java - 合并2排序链表错误答案

git - 在git中 merge 两个远程分支

java - Ant 编译器对特定类文件发出警告

java - 在映射中使用 <cword> 的 VIM 问题

c# - 由 C# 创建的 Word 文档中的表格和单元格 - 如何仅更改一个边框的颜色?

vba - Excel VBA 从禁用宏的实例访问 HelpFile 属性时出现错误?

javascript - 在 MS Word 插件 Javascript API 中读取表格边框的颜色和宽度