From: Alan Knowles Date: Fri, 22 Feb 2013 03:13:33 +0000 (+0800) Subject: SimpleExcel.php X-Git-Url: http://git.roojs.org/?a=commitdiff_plain;h=beafd0510390c71297104150813fb7d4377096f0;p=Pman.Core SimpleExcel.php --- diff --git a/SimpleExcel.php b/SimpleExcel.php index 39486ffa..23a9f167 100644 --- a/SimpleExcel.php +++ b/SimpleExcel.php @@ -246,9 +246,54 @@ class Pman_Core_SimpleExcel extends Pman } - function addLine($worksheet, $data) + function addLine($worksheet_name, $data) { + $cfg = $this->workSheetCfg[$worksheet_name]; + foreach($data as $r=>$clo) { + $cl = $clo; + if (is_object($clo)) { + $cl = (array)$clo; // lossless converstion.. + } + + if (isset($cfg['row_height'])) { + $worksheet->setRow($start_row +$r, $cfg['row_height']); + } + + foreach($cfg['cols'] as $c=>$col_cfg) { + + 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; + } + if (isset($col_cfg['txtrenderer'])) { + $v = call_user_func($col_cfg['txtrenderer'], + $cl[$col_cfg['dataIndex']], $worksheet, $r+1, $c, $clo); + if ($v === false) { + continue; + } + // var_dump($v); + } + if (isset($col_cfg['renderer'])) { + $hasRender = true; + continue; + } + + $v = @iconv('UTF-8', 'UTF-8//IGNORE', $v); + + $format = isset($col_cfg['format']) ? $formats[$col_cfg['format']] : false; + + $worksheet->write($start_row+$r, $c, $v, $format); + } + } }