3

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

I've found 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 ?

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Manuel Leduc
  • 1,849
  • 3
  • 23
  • 39

3 Answers3

4

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>
Alex K
  • 22,315
  • 19
  • 108
  • 236
  • I found this parameter but even when I restart the server it does not change anything. How can I force jasper to use this setting ? – Manuel Leduc Oct 17 '11 at 09:19
  • Did you edit this file: apache-tomcat\webapps\jasperserver\WEB-INF\applicationContext.xml? And set this property: ? – Alex K Oct 17 '11 at 09:31
  • @Manuel Do you mean that exported data (csv file) has comma as delimiter instead of ";" symbol? – Alex K Oct 17 '11 at 09:37
  • I do. And yes I have replaced "," by ";" in applicationContext.xml – Manuel Leduc Oct 17 '11 at 10:00
  • @Manuel I've just set , restart JasperServer and export report data as CVS. The result is: Sales person$$Account$$$$$Amount Sarah Smith$$N & W Creek Transportation Corp$$$$$600,00 For comma separator I had: Sales person,,Account,,,,,Amount Sarah Smith,,N & W Creek Transportation Corp,,,,,"600,00" – Alex K Oct 17 '11 at 10:07
  • Do you have local instance of JasperServer? – Alex K Oct 17 '11 at 10:08
0

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, ";");
Moinul Robin
  • 36
  • 1
  • 10
-1
JRCsvExporter csvExporter = new JRCsvExporter();
csvExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
csvExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, outputStream);
csvExporter.setParameter(JRCsvExporterParameter.FIELD_DELIMITER, ';');
csvExporter.exportReport();
barbsan
  • 3,418
  • 11
  • 21
  • 28