Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
systems:cakephp:cakephp_setup_and_configuration [2015/10/28 16:07] smayr [Configure for Use] |
systems:cakephp:cakephp_setup_and_configuration [2016/05/16 14:18] (current) smayr [Updating Model] |
||
---|---|---|---|
Line 1274: | Line 1274: | ||
echo $pdf-> | echo $pdf-> | ||
+ | </ | ||
+ | |||
+ | === PHPExcel === | ||
+ | |||
+ | * Download a copy of PhpExcel helper and component for CakePHP 2.x: [[https:// | ||
+ | * Copy files to respective folders in CakePHP app. | ||
+ | * Get PHPExcel updates from [[https:// | ||
+ | * See documentation: | ||
+ | * [[https:// | ||
+ | * [[http:// | ||
+ | |||
+ | In PhpExcel helper, edit function '' | ||
+ | <code php> | ||
+ | public function createWorksheet() { | ||
+ | // load vendor classes | ||
+ | App:: | ||
+ | |||
+ | $this-> | ||
+ | $this-> | ||
+ | |||
+ | return $this; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | In controller, add references to helper: | ||
+ | <code php> | ||
+ | class MyController extends AppController | ||
+ | { | ||
+ | ... | ||
+ | | ||
+ | ... | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | In controller, add action to generate data: | ||
+ | <code php> | ||
+ | ... | ||
+ | function actionGetData($id) | ||
+ | { | ||
+ | $data = ClassRegistry:: | ||
+ | ' | ||
+ | )); | ||
+ | | ||
+ | $this-> | ||
+ | | ||
+ | // Create a view that does not display any html header code except for the Excel data. | ||
+ | // To do this, set the layout to be ' | ||
+ | $this-> | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Create view. Eg: actiongetdata | ||
+ | <code php> | ||
+ | // create new empty worksheet and set default font | ||
+ | $this-> | ||
+ | |||
+ | // define table cells | ||
+ | $table = array( | ||
+ | array(' | ||
+ | array(' | ||
+ | array(' | ||
+ | array(' | ||
+ | array(' | ||
+ | ); | ||
+ | |||
+ | // add heading with different font and bold text | ||
+ | $this-> | ||
+ | |||
+ | // add data | ||
+ | foreach ($data as $d) { | ||
+ | $this-> | ||
+ | $d[' | ||
+ | $d[' | ||
+ | $d[' | ||
+ | $d[' | ||
+ | $d[' | ||
+ | )); | ||
+ | } | ||
+ | |||
+ | // close table | ||
+ | $this-> | ||
+ | | ||
+ | // Save to Excel file | ||
+ | ob_end_clean(); | ||
+ | this-> | ||
+ | </ | ||
+ | |||
+ | == Delete Cached Models == | ||
+ | |||
+ | After updating a model, clear the cache to see the changes on the site. | ||
+ | < | ||
+ | $ rm -f / | ||
+ | $ rm -f / | ||
</ | </ |