DataObjects/Core_domain.php
[Pman.Core] / SimpleExcel.php
index 66e261b..c3603ef 100644 (file)
@@ -31,6 +31,7 @@
  *              'dataFormat' => 'string' // to force a string..
                 'width'=>  75,
                 'renderer' => array($this, 'getThumb'),
+                'txtrenderer' => array($this, 'cleanValue'),   // for 
  *              '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
             ),
             
         'leave_open' => false  
             
+            
+        // callbacks: renderer
+        
+        function($value, $worksheet, $row, $col, $row_data)
+        
+        // callbacks : txtrenderer
+        function($value, $worksheet, $row, $col, $row_data)
+                        
+            
+            
  */
  
  
@@ -288,10 +299,14 @@ class Pman_Core_SimpleExcel extends Pman
             $worksheet->setRow($start_row +$r, $cfg['row_height']);
         }
         
-        foreach($cfg['cols']  as $c=>$col_cfg) {
+        $line_height = (isset($cfg['line_height'])) ? $cfg['line_height'] : 12;
+        $height = 0;
+        
+        foreach($cfg['cols']  as $c => $col_cfg) {
             
             if(isset($col_cfg['dataIndex']) && isset($cl[$col_cfg['dataIndex']])){
-                $v = $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']]);
@@ -315,11 +330,10 @@ class Pman_Core_SimpleExcel extends Pman
                 continue;
             }
             
-            $v = @iconv('UTF-8', 'UTF-8//IGNORE', $v);
+            $v = @iconv('UTF-8', 'UTF-8//TRANSLIT//IGNORE', $v);
             
             $dataFormat = empty($col_cfg['dataFormat']) ? '' : $col_cfg['dataFormat'];
-             ;
-            
+              
             
             $format = isset($col_cfg['format'])  && isset($formats[$col_cfg['format']] )   ? $formats[$col_cfg['format']] : false;
           //  print_R(array($start_row+$r, $c, $v, $format));exit;
@@ -327,29 +341,17 @@ class Pman_Core_SimpleExcel extends Pman
             if ( (is_numeric($v) &&  strlen($v) > 1 && substr($v,0,1) == '0' && substr($v,1,1) != '.') 
                     || 
                     $dataFormat == 'string' ) {
-                if($worksheet_name == 'event' && $start_row == 2 && $c == 1){
-                    $validator = $this->workbook->addValidator();
-//                    $validator->setList("a b c");
-                    $validator->_fixedList = 1;
-                    $validator->_type = 3;
-                    $validator->_incell=true;
-                    $validator->setFormula1('INDEX(B10:B11)');
-                    
-//                    $validator->setList('Q2:Q10');
-                    
-                    $this->worksheet->setValidation(2,1,2,1,$validator);
-                    $this->worksheet->_storeDataValidity();
-                    $this->start_row++;
-        
-                    return $hasRender;
-                }
-                
                 $worksheet->writeString($start_row+$r, $c, $v, $format);
-                
             } else {
           
                 $worksheet->write($start_row+$r, $c, $v, $format);
             }
+            
+            if(isset($col_cfg['autoHeight'])){
+                $vv = explode("\n", $v);
+                $height = MAX(count($vv) * $line_height, $height);;
+                $worksheet->setRow($start_row+$r, $height);
+            }
         }
         $this->start_row++;
         
@@ -365,8 +367,10 @@ class Pman_Core_SimpleExcel extends Pman
         }
         
         require_once 'File/Convert.php';
+        //var_Dump($this->outfile2);
         $fc=  new File_Convert($this->outfile2, "application/vnd.ms-excel");
-        $fn = $fc->convert("application/vnd.ms-excel"); 
+        $fn = $fc->convert("application/vnd.ms-excel");
+        //print_r($fc);
         $fc->serve('attachment',$fname); // can fix IE Mess
     }