Asked  7 Months ago    Answers:  5   Viewed   118 times

I'm having a difficult time getting PHPExcel to work. In the class HTML.php, where the object is declared, $objPHPExcel = new PHPExcel(); (on line 153), it can't seem to load PHPExcel. The entire error is:

Fatal error: Class 'PHPExcel' not found in /home/main/public_html/home/IEW/PHPExcel/Reader/HTML.php on line 153

The PHPExcel Library is located at /home/main/public_html/home/IEW/PHPExcel/

(My host is GoDaddy with cpanel is that makes any sort of difference).




For PHPExcel to work properly you have to include PHPExcel.php like this:


Also, in some cases reinstalling whole package can help.

Saturday, May 29, 2021
answered 7 Months ago

I've since fixed this by reinstalling the whole package. Not at all sure what individual file or configuration would have caused the error, might have been to do with previous person to use that code. But anyway, fixed now.

Saturday, May 29, 2021
answered 7 Months ago

'&B' will only set bold text for printed page headers and footers, as described in the section of the documentation entitled Setting the print header and footer of a worksheet

Formatting the content of a cell is described in the section of the documentation entitled Formatting cells, something like:


or (if your content contains actual markup) using Rich Text objects if you only want to set part of the text to bold.

$objRichText = new PHPExcel_RichText();
$objRichText->createText('This text is ');

$objBoldTextRun = $objRichText->createTextRun('bold');

but you will need to parse your markup to convert it to a Rich Text object

Saturday, May 29, 2021
answered 7 Months ago

It's mentioned in the documentation.

    $objRichText = new PHPExcel_RichText();
    $objRichText->createText('This invoice is ');

    $objPayable = $objRichText->createTextRun('payable within thirty days after the end of the month');
    $objPayable->getFont()->setColor( new PHPExcel_Style_Color( PHPExcel_Style_Color::COLOR_DARKGREEN ) );

    $objRichText->createText(', unless specified otherwise on the invoice.');


Saturday, May 29, 2021
answered 7 Months ago

Create an autoloader for PHPExcel and add it to the Zend autoloader stack.

In library/My/Loader/Autoloader/PHPExcel.php:

class My_Loader_Autoloader_PHPExcel implements Zend_Loader_Autoloader_Interface
    public function autoload($class)
        if ('PHPExcel' != $class){
            return false;
        require_once 'PHPExcel.php';
        return $class;

And in application/configs/application.ini:

autoloadernamespaces[] = "My_"

Then, in application/Bootstrap.php:

protected function _initAutoloading()
    $autoloader = Zend_Loader_Autoloader::getInstance();
    $autoloader->pushAutoloader(new My_Loader_Autoloader_PHPExcel());

Then you should be able to instantiate PHPExcel - say, in a controller - with a simple:

$excel = new PHPExcel();

The only sticky part is all of this is how PHPExcel handles loading all its dependencies within its own folder. If that is done intelligently - either with calls like require_once basename(__FILE__) . '/someFile.php' or with its own autoloader that somehow doesn't get in the way of the Zend autoloader - then all should be cool. #famouslastwords

Monday, June 14, 2021
answered 6 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :