Skip to content
This repository has been archived by the owner on Jan 2, 2019. It is now read-only.

Fixed number format fatal error. Occurring on every cell for most excel... #105

Closed
wants to merge 2 commits into from

Conversation

ccorliss
Copy link

@ccorliss ccorliss commented Dec 6, 2012

... sheets I have.

Fatal error: Call to a member function getFormatCode() on a non-object in .......\vendor\phpoffice\phpexcel\Classes\PHPExcel\Worksheet.php on line 2419

…el sheets I have.

Fatal error: Call to a member function getFormatCode() on a non-object in .......\vendor\phpoffice\phpexcel\Classes\PHPExcel\Worksheet.php on line 2419
@ccorliss
Copy link
Author

@MarkBaker Is there anything I can do to help move this pull request along? It's a simple fix, and we can't use the main PHPOffice/PHPExcel branch without it.

@ccorliss
Copy link
Author

ccorliss commented Mar 1, 2013

It was an empty string because that's the default for PHPExcel_Style_NumberFormat::toFormattedString

ie:

public static function toFormattedString($value = '', $format = '', $callBack = null)

I just added a commit defaulting to PHPExcel_Style_NumberFormat::FORMAT_GENERAL if that is preferred.

@MarkBaker
Copy link
Member

Thanks for the fix, and sorry it took me so long to get round to looking at it. I'm afraid I've been busy working on the calcEngine branch, which has focused a lot of my attention. Now I'm running final tests on those changes, and preparing for release, so I hope I'll have a little time to look at some of these merge requests.

@MarkBaker MarkBaker closed this Mar 1, 2013
@laurinkeithdavis
Copy link

I'm confused. The fix applied here does not resolve the issue - at least, not as it's occurring for me.

                            $style = $this->_parent->getCellXfByIndex($cell->getXfIndex());
                            $returnValue[$rRef][$cRef] = PHPExcel_Style_NumberFormat::toFormattedString(
                                $returnValue[$rRef][$cRef],
                                ($style->getNumberFormat()) ?
                                    $style->getNumberFormat()->getFormatCode() :
                                    PHPExcel_Style_NumberFormat::FORMAT_GENERAL
                            );

But the problem is that $style is null and so I get the same error.

@laurinkeithdavis
Copy link

I can change it to this and it works:

                            $style = $this->_parent->getCellXfByIndex($cell->getXfIndex());
                            $returnValue[$rRef][$cRef] = PHPExcel_Style_NumberFormat::toFormattedString(
                                $returnValue[$rRef][$cRef],
                                ($style && $style->getNumberFormat()) ?
                                    $style->getNumberFormat()->getFormatCode() :
                                    PHPExcel_Style_NumberFormat::FORMAT_GENERAL
                            );

@Progi1984 Progi1984 added this to the 1.8.0 milestone Aug 26, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants