【问题标题】:How to properly reformat table in aspose after generation?如何在生成后正确重新格式化 aspose 表?
【发布时间】:2017-06-11 11:44:53
【问题描述】:

有没有办法在 aspose word 中生成表格后通过代码应用一些自定义格式?

【问题讨论】:

    标签: java aspose aspose.words


    【解决方案1】:

    您可以访问所需的 Word 文档表和apply formatting to Table,Row and Cell。请检查以下代码 sn -p 以格式化文档的第一个表格。

    我与 Aspose 合作,担任开发人员宣传员。

    com.aspose.words.Document doc = new com.aspose.words.Document("input.doc");
    com.aspose.words.Table table = (com.aspose.words.Table) doc.getChild(NodeType.TABLE, 0, true);
    
    // Align the table to the center of the page.
    table.setAlignment(TableAlignment.CENTER);
    
    // Clear any existing borders from the table.
    table.clearBorders();
    
    // Set a green border around the table but not inside.
    table.setBorder(BorderType.LEFT, LineStyle.SINGLE, 1.5, Color.GREEN, true);
    table.setBorder(BorderType.RIGHT, LineStyle.SINGLE, 1.5, Color.GREEN, true);
    table.setBorder(BorderType.TOP, LineStyle.SINGLE, 1.5, Color.GREEN, true);
    table.setBorder(BorderType.BOTTOM, LineStyle.SINGLE, 1.5, Color.GREEN, true);
    
    // Fill the cells with a light green solid color.
    table.setShading(TextureIndex.TEXTURE_SOLID, Color.GREEN, Color.GREEN);
    
    doc.save("Table.SetOutlineBorders_Out.doc");
    

    【讨论】:

    • 我测试了这种方法,对我来说最好避免在java中添加样式,最好使用word文档。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-29
    • 1970-01-01
    • 1970-01-01
    • 2016-09-12
    • 2020-06-20
    • 2021-12-07
    相关资源
    最近更新 更多