Search code examples
csvescapingjasper-reports

How to escape double quotes for jasper report?


I'm working on a piece of code, which prepares a CSV-String for jasper in java. Each time when csv-data contains double quotes i get error: net.sf.jasperreports.engine.JRException: Misplaced quote found at position.... Is it possible to escape the quotes programmatically? Or only in template/script file? I've tried u/0022 without success.

with Regards

Rafal Ziolkowski


Solution

  • What you need to do is to enclose the whole value in double quotes and escape double quotes in the data as a pair of double quotes.

    E.g. if you have a "b" c in the data you'll need to put "a ""b"" c" in the CSV.