2017-06-11 1 views

Répondre

0

Vous pouvez accéder à la table souhaitée du document Word et apply formatting to Table,Row and Cell. Veuillez vérifier l'extrait de code suivant pour formater la première table du document. Je travaille avec Aspose comme développeur évangéliste.

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"); 
+0

J'ai testé cette approche et pour moi il vaut mieux éviter d'ajouter des styles en java et il vaut mieux utiliser des documents Word pour cela. – asdasdsdf