Cookbook

Integrate phpxlsx with Zend Framework 1

  • 1- Copy the content of the phpxlsx package and paste it in the library/phpxlsx directory.
  • 2- Open the file index.php of the app and add to it the following lines after the require_once of Zend/Application.php:

x
 
1
// Ensure library/ is on include_path
2
set_include_path(implode(PATH_SEPARATOR, array(
3
    realpath(APPLICATION_PATH . '/../../library/phpxlsx/classes'),
4
    get_include_path(),
5
)));
6
7
/** Phpxlsx */
8
require_once 'CreateXlsx.php';
9

With these two easy steps you are ready to work with phpxlsx. As a practical example, let's create a XLSX in a controller and save it in the public directory with the name output.xlsx:

5
 
1
$xlsx = new CreateXlsx();
2
3
$xlsx->addCell(array('text' => 'New content'), 'A1');
4
$xlsx->saveXlsx(realpath(APPLICATION_PATH . '/../public/') . '/output.xlsx');
5
­
­