Skip to content

Commit

Permalink
Merge pull request #160 from mk-j/2017-09-0.36-r1
Browse files Browse the repository at this point in the history
2017 09 0.36 merge fixes broken example
  • Loading branch information
mk-j authored Dec 2, 2017
2 parents 34188d1 + 27a4f9d commit a754190
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
15 changes: 1 addition & 14 deletions example-cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,14 @@
error_reporting(E_ALL & ~E_NOTICE);

$filename = "example.xlsx";
$as_command_line = php_sapi_name()!='cli' ? true : false;
if ()
{
header('Content-disposition: attachment; filename="'.XLSXWriter::sanitize_filename($filename).'"');
header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
header('Content-Transfer-Encoding: binary');
header('Cache-Control: must-revalidate');
header('Pragma: public');
}

$rows = array(
array('2003','1','-50.5','2010-01-01 23:00:00','2012-12-31 23:00:00'),
array('2003','=B2', '23.5','2010-01-01 00:00:00','2012-12-31 00:00:00'),
array('2003','=B1', '23.5','2010-01-01 00:00:00','2012-12-31 00:00:00'),
);
$writer = new XLSXWriter();
$writer->setAuthor('Some Author');
foreach($rows as $row)
$writer->writeSheetRow('Sheet1', $row);

$writer->writeToFile('example.xlsx');
//$writer->writeToStdOut();
//echo $writer->writeToString();
exit(0);

2 changes: 1 addition & 1 deletion example.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

$rows = array(
array('2003','1','-50.5','2010-01-01 23:00:00','2012-12-31 23:00:00'),
array('2003','=B2', '23.5','2010-01-01 00:00:00','2012-12-31 00:00:00'),
array('2003','=B1', '23.5','2010-01-01 00:00:00','2012-12-31 00:00:00'),
);
$writer = new XLSXWriter();
$writer->setAuthor('Some Author');
Expand Down
3 changes: 3 additions & 0 deletions xlsxwriter.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class XLSXWriter
const EXCEL_2007_MAX_ROW=1048576;
const EXCEL_2007_MAX_COL=16384;
//------------------------------------------------------------------
protected $title ='Doc Title';
protected $author ='Doc Author';
protected $sheets = array();
protected $temp_files = array();
Expand All @@ -33,6 +34,7 @@ public function __construct()
$this->addCellStyle($number_format='GENERAL', $style_string=null);
}

public function setTitle($title='') { $this->title=$title; }
public function setAuthor($author='') { $this->author=$author; }
public function setTempDir($tempdir='') { $this->tempdir=$tempdir; }

Expand Down Expand Up @@ -570,6 +572,7 @@ protected function buildCoreXML()
$core_xml.='<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'."\n";
$core_xml.='<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
$core_xml.='<dcterms:created xsi:type="dcterms:W3CDTF">'.date("Y-m-d\TH:i:s.00\Z").'</dcterms:created>';//$date_time = '2014-10-25T15:54:37.00Z';
$core_xml.='<dc:title>'.self::xmlspecialchars($this->title).'</dc:title>';
$core_xml.='<dc:creator>'.self::xmlspecialchars($this->author).'</dc:creator>';
$core_xml.='<cp:revision>0</cp:revision>';
$core_xml.='</cp:coreProperties>';
Expand Down

0 comments on commit a754190

Please sign in to comment.