freemarker对数字格式的处理

场景,导出word xml时,数字都带有逗号(实际情况要去掉)

如图:

image

 修改,需要如下红色代码设置下

private void generateWordDocument(Map<String, Object> rootMap, OutputStream out) throws Exception {
String filePath = XhxhzjmQzController.class.getClassLoader().getResource("/").getPath()
+ File.separator + "template" + File.separator + "xhxhzjmqz";

Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);
cfg.setDefaultEncoding("UTF-8");
cfg.setDirectoryForTemplateLoading(new File(filePath));
cfg.setNumberFormat("#");

Template temp = cfg.getTemplate("xhbgyl.ftl", "utf-8");
try (Writer writer = new OutputStreamWriter(out, "UTF-8")) {
temp.process(rootMap, writer);
}
}
posted @ 2026-03-06 10:09  爱跳舞的程序员  阅读(1)  评论(0)    收藏  举报