Jump to content
We've recently updated our Privacy Statement, available here ×

[XLS to PDF] Encoding issue (é, è, ç ...)


svi

Recommended Posts

Hi,

 

I work on a report that uses a XLS file for data-source, from which I export the content to a PDF.

Some cells of my XLS contains some 'é' or some 'ç', and those char are not correctly retrieved. For instance, "Message écrit reçu" becomes "Message crit mis". I tried to change de encoding of my text fields in my reports, but the problem seems to be the encoding of my source XLS. However, I tried to save the XLS with other encoding options, but the result was pretty much the same.

I made a variable in order to get the charAt() value of these char, and 'é' gives me 65533.

 

Any ideas ? Thanks :)

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I found the solution, so here it is, for those who face the same issue.

Here is how I was loading my Datasource :

 

JRXlsDataSource ds = new JRXlsDataSource(TestXls.class.getResourceAsStream("fake_d3.xls"));

 

But apparently, JXL assumes that your input file is encoded in UTF-8. So I changed my code for this :

WorkbookSettings ws = new WorkbookSettings();
ws.setEncoding("CP1250");
Workbook wb = Workbook.getWorkbook(TestXls.class.getResourceAsStream("fake_d3.xls"), ws);
JRXlsDataSource ds = new JRXlsDataSource(wb);

 

This works fine. I hope it will help someone else !

Link to comment
Share on other sites

  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...