Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions xlsxwriter.class.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/*
* @license MIT License
* Bug fixes by smiffy6969 as per issues raised on github https://github.com/SystemDevil/PHP_XLSXWriter_plus
* */

if (!class_exists('ZipArchive')) { throw new Exception('ZipArchive not found'); }
Expand Down Expand Up @@ -116,7 +117,7 @@ public function writeToFile($filename)
}


public function writeSheet(array $data, $sheet_name='', array $header_types=array(), array $styles )
public function writeSheet(array $data, $sheet_name='', array $header_types=array(), array $styles=array())
{
for ($i = 0; $i < count($styles); $i++) {
$styles[$i] += array('sheet' => $sheet_name);
Expand Down Expand Up @@ -224,9 +225,9 @@ protected function writeCell($fd, $row_number, $column_number, $value, $sheet_na
}
if (is_numeric($value)) {
fwrite($fd,'<c r="'.$cell.'" s="'.$s.'" t="n"><v>'.($value*1).'</v></c>');//int,float, etc
} else if ($cell_format=='date') {
} else if ($value=='date') {
fwrite($fd,'<c r="'.$cell.'" s="'.$s.'" t="n"><v>'.intval(self::convert_date_time($value)).'</v></c>');
} else if ($cell_format=='datetime') {
} else if ($value=='datetime') {
fwrite($fd,'<c r="'.$cell.'" s="'.$s.'" t="n"><v>'.self::convert_date_time($value).'</v></c>');
} else if ($value==''){
fwrite($fd,'<c r="'.$cell.'" s="'.$s.'"/>');
Expand Down Expand Up @@ -269,12 +270,12 @@ protected function writeStylesXML()
foreach ($this->defaultStyle as $style) {
if (isset($style['sheet'])) {
if (isset($style['font'])) {
if (isset($style['font']['name'])) $this->fontName = $style['font']['name'];
if (isset($style['font']['size'])) $this->fontSize = $style['font']['size'];
if (isset($style['font']['color'])) $this->fontColor = $style['font']['color'];
if ($style['font']['bold']) $this->fontStyles .= '<b/>';
if ($style['font']['italic']) $this->fontStyles .= '<i/>';
if ($style['font']['underline']) $this->fontStyles .= '<u/>';
if (isset($style['font']['name']) && !empty($style['font']['name'])) $this->fontName = $style['font']['name'];
if (isset($style['font']['size']) && !empty($style['font']['size'])) $this->fontSize = $style['font']['size'];
if (isset($style['font']['color']) && !empty($style['font']['color'])) $this->fontColor = $style['font']['color'];
if (isset($style['font']['bold']) && !empty($style['font']['bold'])) $this->fontStyles .= '<b/>';
if (isset($style['font']['italic']) && !empty($style['font']['italic'])) $this->fontStyles .= '<i/>';
if (isset($style['font']['underline']) && !empty($style['font']['underline'])) $this->fontStyles .= '<u/>';

fwrite($fd, ' <font>');
if ($this->fontStyles) fwrite($fd, ' '.$this->fontStyles);
Expand All @@ -284,8 +285,8 @@ protected function writeStylesXML()
} else {
fwrite($fd, ' <color theme="1"/>');
}
fwrite($fd, ' <name val="'.$this->fontName.'"/>');
fwrite($fd, ' <fasmily val="2"/>');
if ($this->fontName) fwrite($fd, ' <name val="'.$this->fontName.'"/>');
fwrite($fd, ' <family val="2"/>');
if ($this->fontName == 'MS Sans Serif') {
fwrite($fd, ' <charset val="204"/>');
} else if ($this->fontName == 'Calibri') {
Expand Down Expand Up @@ -417,6 +418,7 @@ protected function writeStylesXML()
fwrite($fd, '</extLst>');
fwrite($fd, '</styleSheet>');
fclose($fd);

return $tempfile;
}

Expand Down