Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Malformed xlsx file with jruby #99

Open
senolfeldmann opened this issue Jan 15, 2024 · 2 comments
Open

Malformed xlsx file with jruby #99

senolfeldmann opened this issue Jan 15, 2024 · 2 comments

Comments

@senolfeldmann
Copy link

The gem seems to produce faulty xlsx files when using jruby (tested on x86 MacOS and fast_excel 0.5.0). I tried jruby versions 9.2.21.0, 9.3.13.0 and 9.4.5.0.
Excel complains about the xlsx file being corrupted and offers to repair them. After the repair, no files are missing. The same behaviour can be observed even when producing an empty workbook. Steps to reproduce:

require 'fast_excel'

wb = FastExcel.open
# it does not matter what we do in between, whether we add a sheet or not
# the output is "corrupted" nonetheless 
wb.close
@Paxa
Copy link
Owner

Paxa commented Jan 15, 2024 via email

@senolfeldmann
Copy link
Author

senolfeldmann commented Jan 15, 2024

Yes, jruby does indeed support FFI.
I used JRuby 9.3.13.0 and CRuby 2.6.10 (said JRuby version has 2.6.x as a target)

I compared the checksums of all files inside the xlsx/zip and "docProps/core.xml" and "xl/worksheets/sheet1.xml" differ between CRuby and JRuby under MacOS.

for docProps/core.xml dcterms:created and dcterms:modified differ as expected. Everything else is the same, as is their encoding (UTF-8 with LF line-breaks)

xl/worksheets/sheet1.xml seems to be the problem. With CRuby, we get the correct formatting of pageMargins data:
<pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>

When using JRuby, the data is as follows:
<pageMargins left="0,7" right="0,7" top="0,75" bottom="0,75" header="0,3" footer="0,3"/>

My OS is currently set to German, and in German "," is the default decimal separator. When I set the OS language and number format to English, everything works just fine. JRuby somehow refers to the decimal separator set by the OS language, although it shouldn't in this case.

Edit:

The same error also happens on Linux (Tested on Ubuntu Focal). When I set the locale (env variable LC_ALL=de_DE.UTF-8) under Linux, the same error happens. The offending env variable under MacOS is LANG=de_DE.UTF-8). I think this can be closed, as it seems to be a JRuby issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants