getFormatCode with setReadDataOny(FALSE) always return 'General'

Topics: Developer Forum, User Forum
Sep 5, 2013 at 4:48 PM
I have this code:
include 'phpexcel_classes/PHPExcel/IOFactory.php';

$inputFileType = 'Excel2007';

$inputFileName = './master_james.xlsx';

$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objReader->setReadDataOnly(false);
$objReader->setLoadAllSheets();


$sheet = 3;

$objPHPExcel = $objReader->load($inputFileName);


$st = $objPHPExcel->getSheet($sheet)->getCell("G8")->getStyle()->getNumberFormat()->getFormatCode();

print_r($st);

exit;
This have a currency format, but it returns 'General' (I've tested with all the cells of the worksheet, and whatever it have it returns 'General'.

What I'm doing wrong?

Thanks in advance for some help with this.

EB.
Sep 5, 2013 at 6:22 PM
I've have changed my code, the line
$st = $objPHPExcel->getSheet($sheet)->getCell("G8")->getStyle()->getNumberFormat()->getFormatCode();
now is:
$st = $objPHPExcel->getSheet($sheet)->getStyle("G8")->getNumberFormat();
and when I do a print_r of $st there is an(infinite) RECURSION issue:
PHPExcel_Style_NumberFormat Object
(
    [_formatCode:protected] => General
    [_builtInFormatCode:protected] => 0
    [_isSupervisor:protected] => 1
    [_parent:protected] => PHPExcel_Style Object
        (
            [_font:protected] => PHPExcel_Style_Font Object
                (
                    [_name:protected] => Calibri
                    [_size:protected] => 11
                    [_bold:protected] => 
                    [_italic:protected] => 
                    [_superScript:protected] => 
                    [_subScript:protected] => 
                    [_underline:protected] => none
                    [_strikethrough:protected] => 
                    [_color:protected] => PHPExcel_Style_Color Object
                        (
                            [_argb:protected] => FF000000
                            [_parentPropertyName:protected] => _color
                            [_isSupervisor:protected] => 1
                            [_parent:protected] => PHPExcel_Style_Font Object
 *RECURSION*
                        )

                    [_isSupervisor:protected] => 1
                    [_parent:protected] => PHPExcel_Style Object
and so on.

Is that a bug, or am I?

Thanks

EB
Coordinator
Sep 7, 2013 at 7:56 AM
Can you provide an example of your workbook file in the download link from the top of the discussions page