xlsx reading issues (weird output) - Release 1.7.6

Topics: Developer Forum, User Forum
Sep 29, 2011 at 4:31 PM
Edited Sep 29, 2011 at 4:56 PM

PHPExcel version: Release 1.7.6


Hello Guys¡

I have tried over and over to achieve this without sucess, so now i raise a flag for you to help me =(

-I have a php web, and i want to extract some data from an xlsx file and show the content on my website, using an "echo", but heres my situation:

I tried using this code, but is not doing anything:



/** Error reporting */

/** Include path **/
ini_set('include_path', ini_get('include_path').';../Classes/'); //Classes dir

/** PHPExcel_IOFactory */
include 'PHPExcel/IOFactory.php';

$objReader = PHPExcel_IOFactory::createReader('Excel2007');//excel2007
$objPHPExcel = $objReader->load("01simple.xlsx"); //ARCHIVE excel2007 dir
$val = ($objPHPExcel->getActiveSheet()->getCell('A1')); //CELL
$temp = $val->getvalue();//returns the value in the cell
echo ($temp);



I got the previous code from a discussion on this forum, but it doesnt do anything, and if I look on the code, the

issue starts on this line of code:    $objPHPExcel = $objReader->load("01simple.xlsx");

BTW: That "01simple.xlsx" exists, and is stored on the root of the web server, so the issue is not because is not finding

the excel file, but something related with the $objPHPExcel or the $objReader


Then, i tried with this other piece of code that i got from another discusion here on PHPExcel:


require_once 'PHPExcel/IOFactory.php'; 
$objPHPExcel = PHPExcel_IOFactory::load("01simple.xlsx");
    foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
    $worksheetTitle     = $worksheet->getTitle();
    $highestRow         = $worksheet->getHighestRow();
    $highestColumn      = $worksheet->getHighestColumn();
    $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);
    $nrColumns = ord($highestColumn) - 64;
    for ($row = 0; $row <= $highestRow; ++ $row) {
            for ($col = 0; $col < $highestColumnIndex; ++ $col) {
                $cell = $worksheet->getCellByColumnAndRow($col, $row);
                $val = $cell->getValue();
echo ($val);                


This time it prints something on my website¡¡¡¡ But not something readable....

If you go and open the "01simple.xlsx" file on the examples section on this website, you are going to find that it contains something like "Hello Hello  world! world! Miscellaneous glyphs éàèùâêîôûëïüÿäöüç" but instead of that, what is being printed on my website is something like : "PKAx; ѽb%B#+xyCB뎺Oj݃cŗݐɥ}PKAx;};x.W7_&*7WØ  W) 0Pm"

That makes me think that im missing something related to encoding, but since im new on phpExcel, and i already exahusted all the documentation without sucess, then i

request your wisdom in order to help me oh lords of the php world¡

if you can let me know what im doing wrong, or post a code example about how to extract the value of an xlsx spreadsheet cell and then paste it on a web using echo($cell); i will appreciate it forever.


Waiting for your responses.