freemarker对数字格式的处理
场景,导出word xml时,数字都带有逗号(实际情况要去掉)
如图:

修改,需要如下红色代码设置下
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);
}
}

浙公网安备 33010602011771号