Advertisement
Rukmal

Example.php

May 3rd, 2012
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.90 KB | None | 0 0
  1. <?php
  2.  
  3. // When executed in a browser, this script will prompt for download
  4. // of 'test.xls' which can then be opened by Excel or OpenOffice.
  5.  
  6. require 'php-export-data.php';
  7.  
  8. // 'browser' tells the library to stream the data directly to the browser.
  9. // other options are 'file' or 'string'
  10. // 'test.xls' is the filename that the browser will use when attempting to
  11. // save the download
  12. $exporter = new ExportDataExcel('browser', 'test.xls');
  13.  
  14. $exporter->initialize(); // starts streaming data to web browser
  15.  
  16. // pass addRow() an array and it converts it to Excel XML format and sends
  17. // it to the browser
  18. $exporter->addRow(array("This", "is", "a", "test"));
  19. $exporter->addRow(array(1, 2, 3, "123-456-7890"));
  20.  
  21. // doesn't care how many columns you give it
  22. $exporter->addRow(array("foo"));
  23.  
  24. $exporter->finalize(); // writes the footer, flushes remaining data to browser.
  25.  
  26. exit(); // all done
  27.  
  28. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement