public function Excel_XML::generateXML in Views Excel Export 6
Same name and namespace in other branches
- 7 libs/php-excel.class.php \Excel_XML::generateXML()
 
Generate the excel file
Parameters
string $filename Name of excel file to generate (...xls):
File
- libs/
php-excel.class.php, line 152  
Class
- Excel_XML
 - Generating excel documents on-the-fly from PHP5
 
Code
public function generateXML($filename = 'excel-export') {
  // correct/validate filename
  $filename = preg_replace('/[^aA-zZ0-9\\_\\-]/', '', $filename);
  // deliver header (as recommended in php manual)
  header("Content-Type: application/vnd.ms-excel; charset=" . $this->sEncoding);
  header("Content-Disposition: inline; filename=\"" . $filename . ".xls\"");
  // print out document to the browser
  // need to use stripslashes for the damn ">"
  echo stripslashes(sprintf($this->header, $this->sEncoding));
  echo "\n<Worksheet ss:Name=\"" . $this->sWorksheetTitle . "\">\n<Table>\n";
  foreach ($this->lines as $line) {
    echo $line;
  }
  echo "</Table>\n</Worksheet>\n";
  echo $this->footer;
}