public void test() throws Exception {
String resultPath = "D:\\opt\\compare\\图表6.docx";
String savePath = "D:\\opt\\compare\\test\\图表6.html";
String[] key = {"21.17%", "15.00%","营业收入"};
String tage1="12345_";
String tage2="_12345";
String[] value = {tage1+"21.17%"+tage2,tage1+"15.00%"+tage2,tage1+"营业收入"+tage2};
Document document=new Document(resultPath);
for (int i = 0; i < 3; i++) {
//查找整篇文档中所有的数据
FindReplaceOptions options = new FindReplaceOptions();
document.getRange().replace(key[i], value[i], options);
}
HtmlFixedSaveOptions htmlFixedSaveOptions = new HtmlFixedSaveOptions();
htmlFixedSaveOptions.setExportEmbeddedCss(true);
htmlFixedSaveOptions.setExportEmbeddedFonts(true);
htmlFixedSaveOptions.setExportEmbeddedImages(true);
htmlFixedSaveOptions.setShowPageBorder(false);
document.save(savePath,htmlFixedSaveOptions);
}
企业微信截图_16414594816081.png (126.1 KB)
我使用document.getRange().replace()方法将原word中的一些文本进行了替换,替换之后把他们转成了html,我使用浏览器打开了这个html,通过浏览器工具查看html源代码我发现,替换后的文本,例如12345_21.17%_12345被3个标签隔开了(如附件的图片所示),但我不希望它们被隔开,请问我应该怎样设置才能使12345_21.17%_12345被一个标签包裹,而不是被三个span标签包裹?(例如12345_21.17%_12345)