p:dataExporter csv 十进制列不在引号之间

p:dataExporter csv decimal column not between quotation marks

我有一个生成 CSV 文件的 <p:dataExporter>。 不幸的是,小数列不在引号之间。这给我带来了一些问题,因为我的小数点分隔符是逗号。

我该如何解决?也许可以为十进制值加上引号或更改 CSV 分隔符?

逗号作为小数点分隔符是典型的欧洲语言。反过来,欧洲 CSV 格式通常使用分号作为 CSV 分隔符。那应该也能解决这个问题。

但是,<p:dataExporter> 不支持通过某些标记属性更改 CSV 分隔符。逗号在 PrimeFaces CSVExporter source code instead of parameterized. This is also reported as issue 4714 which is currently accepted but still open for more than a year. The issue also mentions Lapis JSF exporter 中被硬编码为数据导出的替代解决方案。

一个快速的解决方法是将原始 CSVExporter source code file 复制粘贴到您的 WAR 中,维护包结构,并编辑它以将所有出现的 writer.write(","); 替换为 writer.write(";");.当在 WAR 和 WAR 的 /WEB-INF/lib 中的 JAR 中发现多个具有相同 FQN 的 类 时, WAR 中的那个将在类加载中获得优先权并且改为使用。