开发者

Semi-colon as separator in jasperreport csv editions

I want to makes my jasperrepport's csv documents values separated with semicolons instead of commas.

I've fou开发者_运维百科nd net.sf.jasperreports.export.csv.field.delimiter parameter which works if i adds it on my jrxml files :

<property name="net.sf.jasperreports.export.csv.field.delimiter" value=";"/>

But what I'm looking for is a global configuration file in my jasper server which can define this configuration key as the default for every csv repport.

Is their a solution for this problem ?


You can set fieldDelimiter property in applicationContext.xml file (you can find it in jasperserver\WEB-INF\ folder) at JasperServer

<bean id="csvExportParameters" class="com.jaspersoft.jasperserver.api.engine.jasperreports.common.CsvExportParametersBean">
    <property name="fieldDelimiter" value=","/>
</bean>


JRCsvExporter works but the above code gave me an error. The following code solved the issue for me...

ADD CHARACTER_ENCODING before you declare the FIELD_DELIMITER. Code sample as follow (follow_up Link for more info):

exporter.setParameter(JRCsvExporterParameter.CHARACTER_ENCODING, "cp1252");
exporter.setParameter(JRCsvExporterParameter.FIELD_DELIMITER, ";");


JRCsvExporter csvExporter = new JRCsvExporter();
csvExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
csvExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, outputStream);
csvExporter.setParameter(JRCsvExporterParameter.FIELD_DELIMITER, ';');
csvExporter.exportReport();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜