java使用aspose.word给表格内容换行

使用row.getCells().insert()插入一个单元格,然后添加内容,这个内容需要手动换行,使用什么符号呢,

现在插入单元格和内容已经实现了,就是手动换行不知道怎么弄,\n没效果

一般都是"\r\n"  aspose.word导出来的内容,换行,貌似wps是正常的,微软的office打开就没有效果。我几年前尝试过。

 

试试

builder.Writeln(); 

测了下free spire.doc.jar,\n换行貌似可以,代码如下(不过这里是获取的单元格插入的内容,\n换行可以,用的微软word测的)

import com.spire.doc.*;

public class test {
    public static void main(String[] args) {
        //加载Word
        Document doc = new Document();
        doc.loadFromFile("sample.docx");

        //获取Section
        Section section = doc.getSections().get(0);

        Table table = section.getTables().get(1);//获取表格
        TableRow row = table.getRows().get(0);
        TableCell cell = row.getCells().get(0);//获取单元格
        cell.getParagraphs().get(0).setText("仅为测试内容\n不用做商业用途");//添加内容,手动设置换行

        //保存
        doc.saveToFile("testresult.docx",FileFormat.Docx_2013);
        doc.dispose();
    }
}