Log in

View Full Version : PHP Excel Special Characters



coops2000
01-08-2008, 04:07 PM
Hi I’m developing a tool that will read in data from an Excel sheet and produce XML files from the data.

Doing this I’ve found a problem. The Excel has changed some of the character into special characters that PHP can’t read.

For Example
EXCEL DATA “Czy przedstawiono Ci instrukcję bezpieczeństwa i higieny pracy (BHP) obowiązującą w firmie?”

Out Put Data “W którym miejscu najlepiej umie[ ci stopy przed podniesieniem ci | aru?W którym miejscu najlepiej umie[ ci stopy przed podniesieniem ci | aru?”


As you can see above it has changed!

I’m using PHP 4 and the below method to read and produce the Output



$data = new Spreadsheet_Excel_Reader();
$data->setUTFEncoder('iconv');
$data->setOutputEncoding("CP-1251");
//$data->setOutputEncoding("UTF-8");
error_reporting(E_ALL ^ E_NOTICE);

$ value = checker($data->sheets[1]['cells'][$j+1][2]);
$newphrase = html_entity_decode($value);


Does anyone know how I can fix this problem???

Thanks

Master_script_maker
01-08-2008, 09:28 PM
when in save as, for excel, set the encoding