Pman.Gnumeric.js
[Pman.Core] / JsonToExcel.php
index ce9d97b..75a24fe 100644 (file)
@@ -28,7 +28,7 @@ class Pman_Core_JsonToExcel extends Pman
         return true;
     }
 
-    function get()
+    function get($v, $opts=array())
     {
         $this->jerr("invalid get");
     }
@@ -46,6 +46,15 @@ class Pman_Core_JsonToExcel extends Pman
         }
         $json = json_decode($_POST['_json']);
         
+        
+        require_once 'Spreadsheet/Excel/Writer.php';
+        // Creating a workbook
+        $outfile2 = $this->tempName('xls');
+       // var_dump($outfile2);
+        $workbook = new Spreadsheet_Excel_Writer($outfile2);
+        //$workbook = new Spreadsheet_Excel_Writer();
+        $workbook->setVersion(8);
+        // sending HTTP headers
         $worksheet =  $workbook->addWorksheet("Sheet 1");
         if (is_a($worksheet, 'PEAR_Error')) {
             die($worksheet->toString());
@@ -60,11 +69,13 @@ class Pman_Core_JsonToExcel extends Pman
             }
             
         }
+         $workbook->close();
         
-        
-         
-          
+        require_once 'File/Convert.php';
+        $fc=  new File_Convert($outfile2, "application/vnd.ms-excel");
+        $fn = $fc->convert("application/vnd.ms-excel"); 
+        $fc->serve('attachment','excel-'.date('Y-m-d-H-i-s').'.xls'); // can fix IE Mess
+        unlink($outfile2); 
     }
-    
-    
+     
 }