javaaspose-cells

Aspose cells - Bad results when saving html workbook to Xlsx on Linux machine


I’m using Aspose cells version 19.10. I have an html file with a table which I would like to save to an Xlsx file.

        HtmlLoadOptions loadOptions = new HtmlLoadOptions();
        loadOptions.setLocale(Locale.GERMANY);
        loadOptions.setRegion(CountryCode.GERMANY);
        loadOptions.setLanguageCode(CountryCode.GERMANY);
        loadOptions.setAutoFitColsAndRows(true);
        loadOptions.setDeleteRedundantSpaces(true);
        loadOptions.setKeepPrecision(true);
        loadOptions.setCheckExcelRestriction(true);

        workbook = new Workbook(inputStream, loadOptions);
        workbook.getSettings().setLocale(Locale.GERMANY);
        workbook.getSettings().setRegion(CountryCode.GERMANY);
        workbook.getSettings().setLanguageCode(CountryCode.GERMANY);
        workbook.getSettings().setNumberDecimalSeparator('.');
        workbook.getSettings().setNumberGroupSeparator(' ');
        workbook.save(targetOutputStream, SaveFormat.XLSX);

On my Windows machine (with German or even English region settings) everything works fine, but on a different Linux machine the results are not correct. So far I noticed two problems in the resulted Xlsx file:

On some cells there are some spaces before and after the number (1.831.100 -> " 1.831.000 " and should be “1,841,100” or “1.831.000”, depending on region formatting ) Some numbers are transformed badly - 5.000 is transformed to 5.000 (but real number is 5) instead of 5,000 (5 thousand)

What do you think could be the cause of these problems on the Linux machine (it’s an Ubuntu 19.10")?

Please advise, Sergiu


Solution

  • In the end I managed to fix the problems by setting the locale to the LoadOptions on loading the doc and also on workbook settings before saving it to xlsx.