javajexcelapi

Java Excel Api character codification issue


I'm developing a java application that reads an Excel file and writes it back to a PDF with some processing inbetween. For reading the spreadsheet I'm using the excellent jExcelApi library, and this is a code excerpt:

workbook = Workbook.getWorkbook(new File(fullName));

Sheet sheet = workbook.getSheet(0);

this.data.customer_name = sheet.getCell("B8").getContents();

Everything works as expected, but I realized that the output is different on the production machine than on the development. It has to do with character encoding. Here's an example of the output file in both computers:

|-------------|-------------|
| Development | Production  |
|-------------|-------------|
| Söderkvist  | S��derkvist |
| Østnes      | ��stnes     |
| Müller      | M��ller     |
|-------------|-------------|

The machines have Ubuntu 16.04 and 17.04 and, although they're not exactly identical, I'm using the same JRE in both. I've been browsing the jExcelApi documentation and I found a WorkbookSettings class with method for getting/setting the character encoding, but I don't know how to get the actual XLS source file encoding. Any ideas?

Thanks!


Solution

  • prod is ASCII dev is UTF-8

    WorkbookSettings workbookSettings = new WorkbookSettings();
    workbookSettings.setEncoding( "UTF-8" );
    Workbook.getWorkbook( theFile, workbookSettings );