0

I'm trying to import a Excel file to my PHP application with PHPExcel but It cannot work correctly with UTF-8 data. This is my data

 Độc quyền

and this is what I retrieve:

 Äá»™c quyá»n

This is my code:

 $cell = $objWorksheet->getCellByColumnAndRow($col, $row);
 $value = $cell->getCalculatedValue();
 $arraydata[$row-2][$col]=$value;

Thanks for your help. :)

Ruồi Trâu
  • 91
  • 2
  • 10
  • PHPExcel ___only___ works with UTF-8.... if a file isn't UTF-8 when loaded, the cell data is converted to UTF-8, if you're loading a filetype without explicit charset such as a CSV file, then you have to tell PHPExcel what charset that file is. How are you displaying your data? – Mark Baker Jul 29 '16 at 09:50
  • I just use print_r() for my test. It works fine with string (like "độc quyền") but it doesn't work with data retrieve from excel file so I think there are some problem with my importing function. I don't understand your sentence "then you have to tell PHPExcel what charset that file is" well. Thanks for your time. :) – Ruồi Trâu Jul 29 '16 at 09:59
  • Any problem with unicode? – Ruồi Trâu Jul 29 '16 at 10:01
  • So what filetype is it that you're loading? What Reader is PHPExcel using to load your file? Is it a real native format Excel file, or a file containg CSV or HTML data? – Mark Baker Jul 29 '16 at 10:04
  • Filetype is Excel2007, I use the newest PHPExcel version – Ruồi Trâu Jul 29 '16 at 10:06
  • Then it should have no problem with UTF-8 data. How are you displayng this data? – Mark Baker Jul 29 '16 at 10:08
  • I use print_t() function, it works fine with text I use to test – Ruồi Trâu Jul 29 '16 at 10:10
  • Then I haven't a clue what you're doing. I know how PHPExcel works, and an OfficeOpenXML file should already be UTF-8, so no conversion is necessary. If you can provide a file to demonstrate your problem, then I can take a look at what might be wrong with it. – Mark Baker Jul 29 '16 at 10:12

0 Answers0