'header'=> "Thumbnail",
'dataIndex'=> 'id',
'width'=> 75,
- 'renderer' => array($this, 'getThumb')
+ 'renderer' => array($this, 'getThumb'),
+ * 'color' => 'yellow', // set color for the cell which is a header element
+ * 'fillBlank' => 'gray', // set the color for the cell which is a blank area
),
// if this is set then it will add a tab foreach one.
function Pman_Core_SimpleExcel($data,$cfg)
{
- // print_r($cfg);
+ // print_r($cfg);exit;
require_once 'Spreadsheet/Excel/Writer.php';
// Creating a workbook
$outfile2 = $this->tempName('xls');
}
}
-
-
-
-
$workbook->close();
$this->outfile2 = $outfile2;
}
- function date($str)
+ static function date($str)
{
- return (strtotime($str) + (86400 * 25569)) / 86400;
+ return (strtotime($str . ' UTC') + (86400 * 25569)) / 86400;
}
function buildpage($workbook, $formats , $data,$cfg)
{
//echo '<PRE>'; print_R($cfg);
-
+ // print_r($cfg);exit;
// Creating a worksheet
$worksheet = $workbook->addWorksheet($cfg['workbook']);
if (is_a($worksheet, 'PEAR_Error')) {
foreach($cfg['cols'] as $c=>$col_cfg) {
-
-
-
- $worksheet->write($start_row, $c, $col_cfg['header']);
+ $format = isset($col_cfg['color']) ? $formats[$col_cfg['color']] : false;
+ $worksheet->write($start_row, $c, $col_cfg['header'],$format);
$worksheet->setColumn ( $c, $c, $col_cfg['width'] / 5);
}
}
foreach($cfg['cols'] as $c=>$col_cfg) {
- $v = isset($cl[$col_cfg['dataIndex']]) ? $cl[$col_cfg['dataIndex']] : '';
+
+ if(isset($cl[$col_cfg['dataIndex']])){
+ $v = $cl[$col_cfg['dataIndex']];
+ }else{
+ if(isset($col_cfg['fillBlank'])){
+ $worksheet->write($start_row+$r, $c, '', $formats[$col_cfg['fillBlank']]);
+ }
+ continue;
+ }
+
if (empty($cl[$col_cfg['dataIndex']])) {
continue;
}
}
$v = @iconv('UTF-8', 'UTF-8//IGNORE', $v);
+
$format = isset($col_cfg['format']) ? $formats[$col_cfg['format']] : false;
- // echo "<PRE>WRITE: ". htmlspecialchars(print_r(array($r+1, $c,$v), true));
$worksheet->write($start_row+$r, $c, $v, $format);
}
}