Java 如何在生成后正确地在aspose中重新格式化表?
在一个word中生成一个表后,有没有办法通过代码应用一些自定义格式?您可以访问所需的word文档表和文档。请检查以下代码段以格式化文档的第一个表 我与Aspose合作,担任开发人员宣传员Java 如何在生成后正确地在aspose中重新格式化表?,java,aspose,aspose.words,Java,Aspose,Aspose.words,在一个word中生成一个表后,有没有办法通过代码应用一些自定义格式?您可以访问所需的word文档表和文档。请检查以下代码段以格式化文档的第一个表 我与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.TA
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文档。