I was recently hit by this issue: https://github.com/jmcnamara/libxlsxwriter/issues/64. The problem is that libxlsxwirter uses sprintf by default which formats decimal numbers in a locale-dependent way, resulting in invalid xlsx files on locales which uses comma as a decimal separator. This is a very confusing problem, as the spreadsheet application I was using (libreoffice calc) did throw any errors on the invalid files, but instead only parses the integer portion of the numbers. Also note that the issue only arises if setlocale is called, possibly in some external library (for me it was possibly gtk?)
A simple solution to solve this problem is to set LC_NUMERIC to C early in main with something like this:
std::env::set_var("LC_NUMERIC", "C");
However it would be preferable to compile libxlsxwriter with USE_DTOA_LIBRARY in order for it to use a locale-independent function. This flag was introduced in https://github.com/jmcnamara/libxlsxwriter/issues/272 and is documented here.
I was recently hit by this issue: https://github.com/jmcnamara/libxlsxwriter/issues/64. The problem is that
libxlsxwirter
usessprintf
by default which formats decimal numbers in a locale-dependent way, resulting in invalid xlsx files on locales which uses comma as a decimal separator. This is a very confusing problem, as the spreadsheet application I was using (libreoffice calc) did throw any errors on the invalid files, but instead only parses the integer portion of the numbers. Also note that the issue only arises ifsetlocale
is called, possibly in some external library (for me it was possibly gtk?)A simple solution to solve this problem is to set
LC_NUMERIC
toC
early inmain
with something like this:However it would be preferable to compile
libxlsxwriter
withUSE_DTOA_LIBRARY
in order for it to use a locale-independent function. This flag was introduced in https://github.com/jmcnamara/libxlsxwriter/issues/272 and is documented here.