-
Notifications
You must be signed in to change notification settings - Fork 914
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
Handling doubles with FFI seems to be locale dependent #8064
Comments
This is very peculiar! Looking at your source links, it seems like a normal I have to assume there's some double-to-string logic running on the Java side, and that logic must be picking up locale somewhere. Are you sure the doubles are being written via the code paths you linked? I'm also confused; you say |
I am not 100% sure yet. I just followed the code starting from the ruby-side of things and did not do any debugging. I did not have the time to dig deeper yet.
Maybe my wording was confusing, sorry for that. JRuby's output is wrong in this case, as the decimal seperator in this particular case should always be a |
@senolfeldmann I am curious if the problem is resolved by changing one or both of those env vars. No doubt we need to get to the bottom of it but knowing which one is causing it might help? It will likely give a temporary workaround if nothing else. |
Environment Information
Other relevant info you may wish to add:
Expected Behavior
The excel file is not malformed when using CRuby. When extract the xlsx file (which is just a zip archive) and inspecting
xl/worksheets/sheet1.xml
, we get the correct formatting of pageMargins the data:Actual Behavior
When using the fast_excel to write excel files with JRuby malformed data is written into
xl/worksheets/sheet1.xml
:The cause seems to be the system locale. I encountered the bug both under MacOS (LANG=de_DE.UTF-8) and Ubuntu Focal (LC_ALL=de_DE.UTF-8). In Germany, the default decimal seperator is "," and not ".".
When looking into the source code of fast_excel (which is an FFI binding for the C-library libxlsxwriter) and its underlying library, I could not find any references to the system locale at the relevant places.
When following the underlying function which writes the page margin data
_worksheet_write_page_margins(lxw_worksheet *self)
infast_excel/libxlsxwriter/src/worksheet.c
you end up at the linestruct xml_attribute *lxw_new_attribute_dbl(const char *key, double value)
infast_excel/libxlsxwriter/src/xmlwriter.c
which tells us that the data is stored and written with doubles as the underlying data type.Please tell me if you need any more info or if I can improve this bug report.
The text was updated successfully, but these errors were encountered: