11 * format = [empty=xls] , 'gnumeric' (download format)
12 * debug = true => download xml.
18 require_once 'Pman.php';
19 class Pman_GnumericToExcel extends Pman
23 $au = $this->getAuthUser();
25 die("NOT authenticated");
27 $this->authUser = $au;
31 function post($fname) {
32 if (empty($_POST['xml'])) {
33 header("HTTP/1.0 400 Internal Server Error");
34 die("Missing XML attribute");
38 $xml = iconv("UTF-8", "UTF-8//IGNORE", $xml);
40 //$xml = str_replace('é', 'e', $xml);
41 //$xml = str_replace("\xA0", ' ', $xml);
42 //$xml = str_replace("Ø", 'dia.',$xml);
44 //$this->addEvent("DOWNLOAD", false, isset($_REQUEST['title']) ? $_REQUEST['title'] : '???');
47 if (!empty($_POST['format']) && $_POST['format']=='gnumeric') {
48 if (empty($_POST['debug'])) {
49 header('Content-type: application/x-gnumeric');
51 header('Content-type: text/xml');
56 $srcTmp = ini_get('session.save_path') . '/' .uniqid('gnumeric_').'.gnumeric';
57 $targetTmp = ini_get('session.save_path') . '/' .uniqid('gnumeric_').'.xls';
58 // write the gnumeric file...
59 $fh = fopen($srcTmp,'w');
64 require_once 'System.php';
65 $ss = System::which('ssconvert');
67 " --import-encoding=Gnumeric_XmlIO:sax" .
68 " --export-type=Gnumeric_Excel:excel_biff8 " .
69 $srcTmp . ' ' . $targetTmp . ' 2>&1';
71 //passthru($cmd);exit;
76 if (!file_exists($targetTmp) || !filesize($targetTmp)) {
77 header("HTTP/1.0 400 Internal Server Error");
78 die("ERROR CONVERTING?:" . $cmd ."\n<BR><BR> OUTPUT:". htmlspecialchars($out));
82 $fh = fopen($targetTmp, 'r');
83 header('Content-type: application/vnd.ms-excel');
84 header('Content-Disposition: attachment; filename="' .addslashes($fname). '"');
86 // will not work on IE... - needs while/fget..