Closed archy-bold closed 7 years ago
Hi,
You are looking for PHPExcel. This project is a PHP extension written in C (wraps the commercial libXL library). Sorry got that wrong in the first read.
Have you tried using setLocale() explicitly?
@johmue Now I feel like a complete idiot for missing something so obvious! Yes, that worked. But I'm not clear why the encoding is set on the first but not on subsequent spreadsheets?
It should work on workbook and not sheet level afaik. ...it took me over a year to spot setLocale() on someone else's code btw ;)
Sorry, I meant workbook, not sheet.
I guess this is a reminder that I should always be clear on as much of the API as possible, rather than just what I need at that moment!
So this is a weird one. I've got a script that I run to generate a large number of reports with php_excel. It runs absolutely fine when run from php cli but has issues when run from an apache2 process.
The issues it has it that the first report generates fine without issue, but all subsequent reports that are generated have issues with:
It, however, has no problems with:
It's clearly an issue with utf-8 encoding, but I don't understand why it's fine on the first generated spreadsheet but all subsequently created reports are affected. I don't do anything obvious to change the encoding. Any ideas?
I'm on PHP 5.4, have the latest master branch of php_excel and am using 3.8.0 of LibXL.
More info on my setup is below.
Here's how I install LibXL and php_excel: https://gist.github.com/archy-bold/361a05fb0d5b572f96f51c122edb2c61
Here's my generic class,
Php_ExcelWriter
, for interfacing with php_excel: https://gist.github.com/archy-bold/a994f4ae332e5efe81862d42be458cb6I do the following:
Php_ExcelWriter->setTemplate()
. That template file will contain a template sheet.Php_ExcelWriter->createNewFromTemplate()
Php_ExcelWriter->insertRowsBefore()
.Php_ExcelWriter->fromArray()
.Php_ExcelWriter->setCellValue()
.Php_ExcelWriter->setCellsCurrency()
.Php_ExcelWriter->writeFile()
which callssave()
on the spreadsheet.Thanks for the help.