You are here

public function Excel_XML::generateXML in Views Excel Export 7

Same name and namespace in other branches
  1. 6 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 214

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<ss:Worksheet ss:Name=\"" . $this->sWorksheetTitle . "\">\n<Table>\n<x:WorksheetOptions/>\n";
  foreach ($this->lines as $line) {
    echo $line;
  }
  echo "</Table>\n</ss:Worksheet>\n";
  echo $this->footer;
}