PHPExcel config file

Apr 14, 2009 at 6:17 PM

What about to make  PHPExcel configuration file and place there all settins like  path to temporary directory,  encodings  etc?

Developer
Apr 15, 2009 at 4:01 AM
I think this may be a matter of taste since it does not really extend what is possible to do with these classes. What are the pros and cons having such a configuration file? We need to discuss this!

Apr 15, 2009 at 12:00 PM
Edited Apr 15, 2009 at 5:51 PM
I encountered some problems with PHPExcel, which could be solved by a configuration file.

One problem was that I get an error when Writer trying to write to a temporary directory, so I had to change permissions on folder with my script.

The second problem is the encodings. Default encoding for russian letters is "Windows-1251" and Writer makes an error on such strings.

That is why i cant write            setCellValue('A1', $MyString)

and I always have to write                   setCellValue('A1', iconv('Windows-1251', 'UTF-8', $MyString))

I think if  I can set this options in config file it will be much better.

Smthing like this:

PHPExcel.config.php:

//Temp directory.  Comment this line to use system default directory

$PHPEXCEL_TEMP_DIR = 'mydir';

//User encodings

$PHPEXCEL_USER_ENCODING = 'Windows-1251';

Developer
Apr 16, 2009 at 5:07 AM
Ok, I see what you mean. Right now, PHPExcel does not support anything like a custom input encoding. I recall that this has been requested long time ago. Today we have the possibility in PHPExcel to define a custom value binder which is like a hook to the setValue() / setCellValue() method. It should be possible to use this to set an input user encoding. This would probably be the clean way of dealing with this. Will see if I can put together an example later.