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 [2014/10/16 15:54] smayr [TCPDF] |
systems:cakephp:cakephp_setup_and_configuration [2016/05/16 14:18] (current) smayr [Updating Model] |
||
---|---|---|---|
Line 15: | Line 15: | ||
</ | </ | ||
+ | Read a config variable using: | ||
+ | Configure:: | ||
== Database Configuration == | == Database Configuration == | ||
Edit file '' | Edit file '' | ||
Line 1272: | 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 / | ||
</ | </ |