Java 不使用apache poi、ms word复制表边框

Java 不使用apache poi、ms word复制表边框,java,ms-word,apache-poi,Java,Ms Word,Apache Poi,我找到了一种将表从一个文档复制到另一个文档的方法,但是表的外部和内部边框不会被复制。我使用的是ApachePOI。你能帮我吗 公共静态无效复制表(XWPFDocument input_doc、XWPFDocument output_doc、, int table_index_输入,int table_index_输出){ XWPFTable template_table=input_doc.getTables().get(table_index_input); CTTbl CTTbl=CTT

我找到了一种将表从一个文档复制到另一个文档的方法,但是表的外部和内部边框不会被复制。我使用的是ApachePOI。你能帮我吗


公共静态无效复制表(XWPFDocument input_doc、XWPFDocument output_doc、,
int table_index_输入,int table_index_输出){
XWPFTable template_table=input_doc.getTables().get(table_index_input);
CTTbl CTTbl=CTTbl.Factory.newInstance();//为新表创建新的CTTbl
ctTbl.set(template_table.getCTTbl());//复制模板表的ctTbl
XWPFTable new_table=新的XWPFTable(ctTbl,output_doc);//在
新建_table.setInsideHBorder(模板_table.getInsideHBorderType()、模板_table.getInsideHBorderSize()、模板_table.getInsideHBorderSpace()、模板_table.getInsideHBorderColor());
新建_table.setInsideVBorder(模板_table.getInsideVBorderType()、模板_table.getInsideVBorderSize()、模板_table.getInsideVBorderSpace()、模板_table.getInsideVBorderColor());
新建_table.getCTTbl().setTblPr(模板_table.getCTTbl().getTblPr());
新建_table.getCTTbl().setTblGrid(模板_table.getCTTbl().getTblGrid());
输出_doc.create段落();
output_doc.createTable();//在文档中创建一个空表
output_doc.setTable(table_index_output,new_table);//将空表替换为table 2
}

有帮助吗?@PaulT。它对我没有帮助,或者我没有正确地使用它。可能您的
input\u doc
的表格样式没有直接在表格的
XML
中设置。相反,它们可能是在
/word/styles.xml
中设置的。因此,
/word/styles.xml
部分也必须被复制。不太可行。我已经放弃了将零件从模板复制到目标的方法。而是打开模板,更改该模板,然后将更改后的模板另存为目标。