GnumericToExcel.php
authorAlan Knowles <alan@akbkhome.com>
Mon, 13 Dec 2010 07:39:42 +0000 (15:39 +0800)
committerAlan Knowles <alan@akbkhome.com>
Mon, 13 Dec 2010 07:39:42 +0000 (15:39 +0800)
GnumericToExcel.php

index f53c8bc..76c3ac3 100644 (file)
@@ -93,10 +93,16 @@ class Pman_Core_GnumericToExcel extends Pman
        
         header('Content-type: application/vnd.ms-excel');
         header('Content-Disposition: attachment; filename="' .addslashes($fname). '"');
-        header('Content-length: '. filesize($targetTmp));
-        $fh = fopen($targetTmp, 'r');
-        // will not work on IE... - needs while/fget..
-        fpassthru($fh);
+        header('Content-length: '. filesize($targetTmp));   
+        header("Content-Transfer-Encoding: binary");
+        if ($file = fopen($targetTmp, 'rb')) {
+            while(!feof($file) and (connection_status()==0)) {
+                print(fread($file, 1024*8));
+                flush();
+            }
+            fclose($file);
+        }
+       
         unlink($targetTmp);
         exit;