if (!empty($cfg['workbook'])) {
- $this->buildPage( $formats , $data,$cfg);
+ $this->buildPage( array(), $data,$cfg);
} elseif (!empty($cfg['workbooks'])) {
foreach($cfg['workbooks'] as $i =>$wcfg) {
- $this->buildPage( $formats , $data[$i],$wcfg);
+ $this->buildPage( array() , $data[$i],$wcfg);
}
}
//$this->formats = (array)$formats;
-
+ foreach($formats as $k=>$fcfg) {
+ if (!isset($this->formats[$f])) {
+ $this->formats[$f] = & $workbook->addFormat();
+ }
+ if (is_a($fcfg,'Spreadsheet_Excel_Writer_Format')) {
+ continue; // skip!?!?
+ }
+ // not an object..
+ foreach((array)$fcfg as $k=>$v) {
+ $this->formats[$f]->{'set' . $k}($v);
+ }
+ }
if (isset($cfg['formats'])) {
foreach($cfg['head'] as $row) {
foreach($row as $c => $col) {
if (is_array($col)) {
- $format = isset($formats[$col[1]] ) ? $formats[$col[1]] : false;
+ $format = isset($this->formats[$col[1]] ) ?$this->formats[$col[1]] : false;
$worksheet->write($start_row, $c, $col[0], $format);
continue;
}
foreach($cfg['cols'] as $c=>$col_cfg) {
- $format = isset($col_cfg['color']) ? $formats[$col_cfg['color']] : false;
- $worksheet->write($start_row, $c, $col_cfg['header'],$format);
+
+ $format = isset($col_cfg['color']) && isset($this->formats[$col_cfg['color']]) ? $this->formats[$col_cfg['color']] : false;
+ $worksheet->write($start_row, $c, @$col_cfg['header'],$format);
$worksheet->setColumn ( $c, $c, $col_cfg['width'] / 5);
}
$start_row++;
foreach($row as $c => $col) {
// if it's an array? - formated ???
if (is_array($col)) {
- $format = isset($formats[$col[1]] ) ? $formats[$col[1]] : false;
+ $format = isset($this->formats[$col[1]] ) ? $this->formats[$col[1]] : false;
$worksheet->write($start_row, $c, $col[0], $format);
continue;
}
// add a spacer..
$start_row++;
}
-
-
+
}
function addLine($worksheet_name, $clo)
foreach($cfg['cols'] as $c=>$col_cfg) {
- if(isset($cl[$col_cfg['dataIndex']])){
+ if(isset($col_cfg['dataIndex']) && isset($cl[$col_cfg['dataIndex']])){
$v = $cl[$col_cfg['dataIndex']];
}else{
if(isset($col_cfg['fillBlank'])){