iliaal / php_excel

PHP Extension interface to the Excel writing/reading library
http://ilia.ws
533 stars 131 forks source link

sometimes fail in generating 300 cols x 2,000 rows excel sheet #242

Closed GitOkaKaz closed 5 years ago

GitOkaKaz commented 5 years ago

I tested libxl and wrote to a excel sheet, using data size of 300 cols x 2,000 rows. Strangely, the program sometimes succesfully ends (without no problem), but sometimes, the program generates the sheet partially only (this means, some columns having valid data, while other columns having empty).

I try to open the excel files (both patterns of Failed and Success), after renaming the extension (from XLSX to ZIP), and I discovered there are some variances between those two files.

Especially, below file is the one with variances: Folder -> xl -> sharedStrings.xml

Please find more detail in the following sample (actual one):

**Not OK version (the string is missing) <?xml version="1.0" encoding="UTF-8"?><sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="600000" uniqueCount="1"><si><t/></si></sst>

**OK version (with the string outputted properly) <?xml version="1.0" encoding="UTF-8"?><sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="600000" uniqueCount="1"><si><t>SOME MESSAGE I PUT IN THE SHEET</t></si></sst>

Hopefully I can get some feedback about my finding.

johmue commented 5 years ago

Can you please provide a code snippet which reproduces the error. A simple loop would be sufficient. It's hard to say where the problem occurs - could be php_excel, could be libxl - could be even your program. Thx

GitOkaKaz commented 5 years ago

Thanks for your advise, and sorry for the late reply. I could identify the cause finally, here is some information to share.

Before, my code was like: $excel = new ExcelBook(NULL, NULL, TRUE); Then, I added the setLocale command, like this: $excel = new ExcelBook(NULL, NULL, TRUE); $excel->setLocale('ja_JP.UTF-8'); This solved my problem.

My example excel file, which containts both of Japanese and English letters, can now be generated normally, thanks to the effect of setLocale.

Thanks again.