简体   繁体   English

如何在生成后正确地重新格式化表?

[英]How to properly reformat table in aspose after generation?

有没有一种方法可以在用aspose单词生成表格后通过代码应用一些自定义格式?

You can access desired table of Word document and apply formatting to Table,Row and Cell . 您可以访问所需的Word文档表,并将格式应用于Table,Row和Cell Please check following code snippet to format first table of the document. 请检查以下代码片段以格式化文档的第一张表。

I work with Aspose as developer Evangelist. 我与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");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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