Firefox vs IE on Excel File Generation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • andrewteg
    New Member
    • Aug 2007
    • 22

    Firefox vs IE on Excel File Generation

    I am using a script to generate XL files by just sending headers and even if I only send one row of data, it takes forever for the Firefox box to allow me to Open/Save the file ... however, in IE it comes up almost instantly, even when there are around 100 rows of data.

    Does anyone have any idea why this could be? It seems like a Firefox setting but I don't know what setting it could/would be.

    Thanks,
    Andrew
  • TheServant
    Recognized Expert Top Contributor
    • Feb 2008
    • 1168

    #2
    Originally posted by andrewteg
    I am using a script to generate XL files by just sending headers and even if I only send one row of data, it takes forever for the Firefox box to allow me to Open/Save the file ... however, in IE it comes up almost instantly, even when there are around 100 rows of data.

    Does anyone have any idea why this could be? It seems like a Firefox setting but I don't know what setting it could/would be.

    Thanks,
    Andrew
    If it works on both, generally it means that it is the browser rather than your code. However, if you have an error in your code and that error is better dealt with on IE than Firefox, then that could also do it. Check your script for errors and also try it on Opera or even evil Safari. If it is a small script post it here so we can try and find your error (if you have one). Otherwise ask Firefox support for their opinion.

    Comment

    • andrewteg
      New Member
      • Aug 2007
      • 22

      #3
      Here is my code for generating an XL sheet based on a query that's been built in another page. It's 32 lines but is a pretty basic loop. If I comment out the 4 headers at the end it loads the tab-delimited text well in both browsers so perhaps I'm using the wrong header or header settings?

      [PHP]
      $table = "Custom"; if (isset($_GET['table'])) $table = strtoupper($_GE T['table']);
      $header = "";
      $data = "";
      $strSQL = "SELECT * FROM Table"; //really a session var
      //echo "<BR>".$strSQL. "<BR>";
      $result = mysql_query($st rSQL);
      $fields = mysql_num_field s($result);
      for ($i = 0; $i < $fields; $i++) {
      $header .= mysql_field_nam e($result, $i) . "\t";
      }
      while($row = mysql_fetch_row ($result)) {
      $line = '';
      foreach($row as $value) {
      if ((!isset($value )) OR ($value == "")) {
      $value = "\t";
      } else {
      $value = str_replace('"' , '""', $value);
      $value = '"' . $value . '"' . "\t";
      }
      $line .= $value;
      }
      $data .= trim($line)."\n ";
      }
      $data = str_replace("\r ","",$data) ;
      if ($data == "") {
      $data = "\n(0) Records Found!\n";
      }
      header("Content-type: application/x-msdownload");
      header("Content-Disposition: attachment; filename=".$tab le."_Query.xls" );
      header("Pragma: no-cache");
      header("Expires : 0");
      echo "$header\n$data ";
      [/PHP]

      Comment

      • andrewteg
        New Member
        • Aug 2007
        • 22

        #4
        Quick Update: I just tried[PHP]header("Content-type: application/vnd.msexcel"); //application/x-msdownload OR application/vnd.msexcel OR ???[/PHP] and got the same results where it seems a lot better in IE than FF.

        Comment

        Working...