请问下,使用spire读取word中的table表格后,然后输出到新的文档中为什么表的边框全都变成虚线了
原来的:
复制后:
public class RemoveNewLine {
public static void main(String[] args) {
//加载文档
Document doc = new Document();
doc.loadFromFile("sample.docx");
//获取第一个表格
Table table = doc.getSections().get(0).getTables().get(0);
//获取第一个单元格
TableCell cell = table.getRows().get(0).getCells().get(0);
//在单元格中添加新的段落
Paragraph newPara = new Paragraph(doc);
newPara.appendText("New Content");
cell.getParagraphs().add(newPara);
//保存文档
doc.saveToFile("sample_updated.docx", FileFormat.Docx);
}
}
增加代码
//获取表格边框对象
Border border = cell.getCellBorder();
//将表格边框设置为实线
border.setColor(BaseColor.BLACK);
border.setWidth(1f);
cell.setCellBorder(border);
使用表格单元格的CellBorder属性获取表格边框,并将其设置为实线