Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. <?php
  2.  
  3. public function export()
  4. {
  5. $headings = [['Id', 'Prosjektnr', 'Navn', 'Kunde', 'Status']];
  6. $projects = $this->Projects
  7. ->find()
  8. ->select(['id', 'number', 'name', 'customer', 'status'])
  9. ->toArray();
  10.  
  11. // debug($projects); $this->render(false);
  12.  
  13. $_serialize = ['headings', 'projects'];
  14. $_delimiter = ';';
  15. $_enclosure = '';
  16. $_newline = '\r\n';
  17. // $_extension = 'utf8_decode';
  18. // $_bom = true;
  19.  
  20. $this->response->download('projects.csv'); // <= setting the file name
  21. $this->viewBuilder()->className('CsvView.Csv');
  22. $this->set(compact('headings', 'projects', '_serialize', '_delimiter', '_enclosure', '_newline'));
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement