Hello,
import com.aspose.words.Table;
Table table;
for (Row row : table.getRows()){
mso-fareast-font-family:“Times New Roman”;mso-ansi-language:FR;mso-fareast-language:
FR;mso-bidi-language:AR-SA”>
Hello,
Hi
Thanks for your request. There is not direct way to specify border around a table. You can achieve this by setting borders of each cell in the first row, last row, first column and last column. For example, see the following code and attached documents:
// Open document
Document doc = new Document("C:\\Temp\\in.doc");
// Get table
Table tab = doc.getFirstSection().getBody().getTables().get(0);
// Set top border of the table
for(Cell cell : tab.getFirstRow().getCells())
{
cell.getCellFormat().getBorders().getTop().setLineStyle(LineStyle.SINGLE);
cell.getCellFormat().getBorders().getTop().setColor(Color.RED);
cell.getCellFormat().getBorders().getTop().setLineWidth(3);
}
// Set bottom border of the table
for(Cell cell : tab.getLastRow().getCells())
{
cell.getCellFormat().getBorders().getBottom().setLineStyle(LineStyle.SINGLE);
cell.getCellFormat().getBorders().getBottom().setColor(Color.RED);
cell.getCellFormat().getBorders().getBottom().setLineWidth(3);
}
// Set left and right borders of the table
for(Row row : tab.getRows())
{
row.getFirstCell().getCellFormat().getBorders().getLeft().setLineStyle(LineStyle.SINGLE);
row.getFirstCell().getCellFormat().getBorders().getLeft().setColor(Color.RED);
row.getFirstCell().getCellFormat().getBorders().getLeft().setLineWidth(3);
row.getLastCell().getCellFormat().getBorders().getRight().setLineStyle(LineStyle.SINGLE);
row.getLastCell().getCellFormat().getBorders().getRight().setColor(Color.RED);
row.getLastCell().getCellFormat().getBorders().getRight().setLineWidth(3);
}
// Save output document
doc.save("C:\\Temp\\out.doc");
Hope this helps.
Best regards.
Thank you Alexey, it’s working!