JsonToExcel.php
[Pman.Core] / JsonToExcel.php
1 <?php
2
3 /**
4  * 
5  * MOVE To Core ---
6  * 
7  * Usage:
8  * 
9  * POST Values: 
10  *  xml = data
11  *  format = [empty=xls] , 'gnumeric'  (download format)
12  *  debug = true => download xml.
13  * 
14  * 
15  * 
16  */
17
18 require_once 'Pman.php';
19 class Pman_Core_JsonToExcel extends Pman
20 {
21     function getAuth()
22     {
23         $au = $this->getAuthUser();
24         if (!$au) {
25             die("NOT authenticated");
26         }
27         $this->authUser = $au;
28         return true;
29     }
30
31     function get()
32     {
33         $this->jerr("invalid get");
34     }
35     function post($fname) {
36         
37         $ml = (int) ini_get('suhosin.post.max_value_length');
38         if (empty($_POST['_json'])) {
39             header("HTTP/1.0 400 Internal Server Error");
40             die(  $ml ? "Suhosin Patch enabled - try and disable it!!!" : 'no JSON sent');
41         }
42         
43         if (empty($_POST['_json'])) {
44             header("HTTP/1.0 400 Internal Server Error");
45             die("Missing json attribute");
46         }
47         $_json = $_POST['_json'];
48         
49         $worksheet =  $workbook->addWorksheet("Sheet 1");
50         if (is_a($worksheet, 'PEAR_Error')) {
51             die($worksheet->toString());
52         }
53         //print_R($worksheet);
54         $worksheet->setInputEncoding('UTF-8'); 
55          
56           
57     }
58     
59     
60 }