X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=blobdiff_plain;f=GnumericToExcel.php;h=5ce821deb6d17a0e23a68e9ff6c2bcebb6472a85;hp=527e103409ae8ee6cba9dfbea45032d911fcac25;hb=HEAD;hpb=acd86626b8db386ca9fc3b1dbd1a4b819afeaf5b
diff --git a/GnumericToExcel.php b/GnumericToExcel.php
index 527e1034..feb940c3 100644
--- a/GnumericToExcel.php
+++ b/GnumericToExcel.php
@@ -30,7 +30,7 @@ class Pman_Core_GnumericToExcel extends Pman
function get($v, $opts=array())
{
-
+
}
function post($fname) {
@@ -66,10 +66,13 @@ class Pman_Core_GnumericToExcel extends Pman
exit;
}
- $ext = '.xls';
+ $ext = 'xls';
$outfmt = 'Gnumeric_Excel:excel_biff8';
$mime = 'application/vnd.ms-excel';
- /* if (!empty($_POST['format']) && $_POST['format']=='xlsx') {
+
+ /*
+ // ssconvert results in bad images
+ if (!empty($_POST['format']) && $_POST['format']=='xlsx') {
$outfmt = 'Gnumeric_Excel:xlsx';
$ext = 'xlsx';
$mime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
@@ -95,7 +98,7 @@ class Pman_Core_GnumericToExcel extends Pman
" --export-type={$outfmt} " .
$srcTmp . ' ' . $targetTmp . ' 2>&1';
// echo $cmd;
- //passthru($cmd);exit;
+ //passthru($cmd);exit;
//exit;
$out = `$cmd`;
clearstatcache();
@@ -104,26 +107,35 @@ class Pman_Core_GnumericToExcel extends Pman
header("HTTP/1.0 400 Internal Server Error - Convert error");
die("ERROR CONVERTING?:" . $cmd ."\n
OUTPUT:". htmlspecialchars($out));
}
+
if (!empty($_POST['format']) && $_POST['format']=='xlsx') {
require_once 'File/Convert.php';
$cc = new File_Convert($targetTmp,'application/vnd.ms-excel');
-
$targetTmp = $cc->convert('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
- $mime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
- $ext = ".xlsx";
+ if (empty($targetTmp)) {
+ $this->jerr("convert to xlsx failed");
+ }
+
+ $mime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
+ $ext = "xlsx";
}
-
-
-
-
-
-
- // unlink($srcTmp);
if (empty($fname)) {
$fname = basename($targetTmp);
}
$fname .= preg_match('/\.' . $ext . '/i', $fname) ? '' : ('.' . $ext); // make sure it ends in xls..
+
+ DB_DataObject::factory('Events')->addFile(array(
+ 'tmp_name' => $targetTmp,
+ 'name' => $fname,
+ 'type' => $mime,
+ 'size' => filesize($targetTmp)
+ ));
+
+ $this->addEvent("DOWNLOAD", false, $fname );
+
+ // unlink($srcTmp);
+
header('Content-type: ' . $mime);
header('Content-Disposition: attachment; filename="' .addslashes($fname). '"');
header('Content-length: '. filesize($targetTmp));