SimpleExcel.php
[Pman.Core] / SimpleExcel.php
index 9213290..155c792 100644 (file)
@@ -33,7 +33,7 @@ new Pman_Core_SimpleExcel($data_array, array(
                 'dataFormat' => 'string' // to force a string..
                 'width'=>  75,
                 'renderer' => array($this, 'getThumb'),
-                'txtrenderer' => array($this, 'cleanValue'),   // for 
+                'txtrenderer' => array($this, 'cleanValue'),   // for text content...
                 '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
             ),
@@ -254,8 +254,13 @@ class Pman_Core_SimpleExcel extends Pman
                         continue;
                     }
                     if (isset($col_cfg['renderer'])) {
+                        
+                        if (is_a($col_cfg['renderer'], 'Closure')) {
+                            $col_cfg['renderer']->call($cl[$col_cfg['dataIndex']], $worksheet, $r+1, $c, $cl);
+                        } else {
                         // not sure if row is correct here...!!!?
-                        call_user_func($col_cfg['renderer'], $cl[$col_cfg['dataIndex']], $worksheet, $r+1, $c, $cl);
+                            call_user_func($col_cfg['renderer'], $cl[$col_cfg['dataIndex']], $worksheet, $r+1, $c, $cl);
+                        }
                         
                     }
                   //  echo "<PRE>WRITE: ". htmlspecialchars(print_r(array($r+1, $c, $cl[$col_cfg['dataIndex']]), true));
@@ -323,8 +328,13 @@ class Pman_Core_SimpleExcel extends Pman
                 continue;
             }
             if (isset($col_cfg['txtrenderer'])) {
-                $v = call_user_func($col_cfg['txtrenderer'], 
-                        $cl[$col_cfg['dataIndex']], $worksheet, $r+1, $c, $clo);
+                
+                 if (is_a($col_cfg['txtrenderer'], 'Closure')) {
+                    $v =     $col_cfg['txtrenderer']->call($cl[$col_cfg['dataIndex']], $worksheet, $r+1, $c, $clo);
+                } else {
+                    $v = call_user_func($col_cfg['txtrenderer'], 
+                            $cl[$col_cfg['dataIndex']], $worksheet, $r+1, $c, $clo);
+                }
                 if ($v === false) {
                     continue;
                 }