2017 © Pedro PelĂĄez
 

cakephp-plugin cake-php-excel

CakePHP excel generator using PHPExcel library

image

maraya/cake-php-excel

CakePHP excel generator using PHPExcel library

  • Monday, February 23, 2015
  • by maraya
  • Repository
  • 1 Watchers
  • 5 Stars
  • 2,126 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 9 Versions
  • 2 % Grown

The README.md

CakePHPExcel

A plugin to generate Excel files with CakePHP. Uses CakePHP view files to generate them (with PHPExcel_IOFactory class from PHPExcel)., (*1)

Requirements

  • PHP 5.2.8
  • CakePHP 2.1+
  • PHPExcel
  • Composer

Installation

Add to your composer.json file (maraya/cake-php-excel), (*2)

"require": {
    "maraya/cake-php-excel": "1.1.*"
},
"config": {
    "vendor-dir": "Vendor/"
},
"extra": {
    "installer-paths": {
        "Plugin/CakePHPExcel": ["maraya/cake-php-excel"]
    }
}

And run, (*3)

composer update

Usage

In app/Config/bootstrap.php add:, (*4)

CakePlugin::load('CakePHPExcel', 
    array(
        'routes' => true
    )
);

Add the RequestHandler component to AppController, and map Excel extensions to the CakePHPExcel plugin, (*5)

'RequestHandler' => array(
    'viewClassMap' => array(
        'xls' => 'CakeExcel.Excel',
        'xlsx' => 'CakeExcel.Excel'
    )
),

Create Layouts/xls/default.ctp (in this example the charset is UTF-8), (*6)

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
    <?php echo $this->fetch('content'); ?>
</body>
</html>

Place the view templates in a xls subdir, for example: app/View/Reports/xls/clients.ctp, (*7)

<h1>Title</h1>
<table width="100%" border="1">
    <tr>
        <td>col1</td>
        <td>col2</td>
        <td>col3</td>
    </tr>
    <tr>
        <td>val1</td>
        <td>val2</td>
        <td>val3</td>
    </tr>
</table>

And in your controller:, (*8)

class ReportsController extends AppController {
    public function clients() {
        $this->excelConfig =  array(
            'filename' => 'clients.xlsx'
        );
    }
}

Call the URL, (*9)

http://example.com/reports/clients.xlsx

If you want to download Excel5 format, change the URL extension from xlsx to xls., (*10)

Inside your view file you can write HTML code. Please see the PHPExcel documentation for a guide on how to use PHPExcel., (*11)

The Versions

23/02 2015

dev-master

9999999-dev https://github.com/maraya/CakePHPExcel

CakePHP excel generator using PHPExcel library

  Sources   Download

MIT

The Requires

 

by Marcelo Araya-GĂłmez Reyes

cakephp excel phpexcel maraya

23/02 2015

v1.1.2

1.1.2.0 https://github.com/maraya/CakePHPExcel

CakePHP excel generator using PHPExcel library

  Sources   Download

MIT

The Requires

 

by Marcelo Araya-GĂłmez Reyes

cakephp excel phpexcel maraya

23/02 2015

dev-dev

dev-dev https://github.com/maraya/CakePHPExcel

CakePHP excel generator using PHPExcel library

  Sources   Download

MIT

The Requires

 

by Marcelo Araya-GĂłmez Reyes

cakephp excel phpexcel maraya

23/02 2015

v1.1.1

1.1.1.0 https://github.com/maraya/CakePHPExcel

CakePHP excel generator using PHPExcel library

  Sources   Download

MIT

The Requires

 

by Marcelo Araya-GĂłmez Reyes

cakephp excel phpexcel maraya

19/02 2015

v1.1.0

1.1.0.0 https://github.com/maraya/CakePHPExcel

CakePHP excel generator using PHPExcel library

  Sources   Download

MIT

The Requires

 

by Marcelo Araya-GĂłmez Reyes

cakephp excel phpexcel maraya

20/11 2014

v1.0.3

1.0.3.0 https://github.com/maraya/CakePHPExcel

CakePHP excel generator using PHPExcel library

  Sources   Download

MIT

The Requires

 

by Marcelo Araya-GĂłmez Reyes

cakephp excel phpexcel maraya

19/11 2014

v1.0.2

1.0.2.0 https://github.com/maraya/CakePHPExcel

CakePHP excel generator using PHPExcel library

  Sources   Download

MIT

The Requires

 

by Marcelo Araya-GĂłmez Reyes

cakephp excel phpexcel maraya

19/11 2014

v1.0.1

1.0.1.0 https://github.com/maraya/CakePHPExcel

CakePHP excel generator using PHPExcel library

  Sources   Download

MIT

The Requires

 

by Marcelo Araya-GĂłmez Reyes

cakephp excel phpexcel maraya

19/11 2014

v1.0.0

1.0.0.0 https://github.com/maraya/CakePHPExcel

CakePHP excel generator using PHPExcel library

  Sources   Download

MIT

The Requires

 

by Marcelo Araya-GĂłmez Reyes

cakephp excel phpexcel maraya