Feb 5, 2010 at 3:33 PM
Edited Feb 5, 2010 at 3:34 PM
I'm trying to create a spreadsheet which takes some of its cell values from an xml file, but when I try to insert words with foreign characters in them, it fails.
The xml file has utf-8 encoding.
I am creating an Excel 5 sheet using
$objPHPExcel = new PHPExcel();
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
I have tried using iconv and mbstring to encode the string before it is entered into the cell
$current_enc = mb_detect_encoding($str);
$objPHPExcel->setActiveSheetIndex(0)->setCellValue('B1', iconv($current_enc, "UTF-8", $str));
$objPHPExcel->setActiveSheetIndex(0)->setCellValue('B1', mb_convert_encoding($str, "UTF-8", $current_enc));
and I get the same result each time.
If i am trying to insert a string like "Tvättsäck" it appears in the spreadsheet as "Tv"
Any help would be greatly appreciated.
This has been a really useful class so far, we are using it to embed images into the spreadsheet, which I think is why we went for the Excel5 type of file.