Jump to content

wahoomike

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

wahoomike's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. hey everyone, I have a php script that dumps an sql query to an excel file for download (based on the tutorial on this site). the code works fine in firefox, downloads as the right file type, name (submission.xls), etc. however, IE downloads the file as an excel file whose name is the name of the script (event_results.php?display=true&rend=xl), which in turn causes excel to generate an error when attempting to open the file. what could cause this? thanks very much for the help. here's the code i'm using: [code] // Start the session session_start(); ob_start(); // Fetch the event's id and render method $eid = $_GET['eid']; $renderMethod = $_GET['rend']; if(!$_SESSION['user'] || (!$_SESSION['isSuper'] && !RegistrationAdmin::checkEventOwner($eid, $_SESSION['userId']))){ //no echo's or header info     echo "You are not authorized to view this page."; } else {     // Fetch the submitted data for this event     $submissionData = RegistrationAdmin::fetchEventSubmissionData($eid); //no echo's or header info          if($submissionData){         //Extract the headings for each column         $tmpArr = array_values($submissionData);         $headings = array_keys($tmpArr[0]);                  // Render the results appropriately         switch($renderMethod){             case "xl":                     // Send the proper headers for an excel download                     header("Content-type: application/vnd.ms-excel");                     header("Expires: 0");                     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");                     header("Content-Disposition: attachment; filename=org_data.xls");                     //header("Pragma: no-cache");                                          // Render the data in an excel file                     $renderStr = "";                                          foreach ($headings as $heading){                         $renderStr .= "\"$heading\"\t";                     }                     $renderStr .= "\n";                                          foreach ($submissionData as $submission){                         foreach ($headings as $heading){                             $renderStr .= "\"".$submission[$heading]."\"\t";                         }                         $renderStr .= "\n";                     }                     break;             case "txt":                 break;             default:                 // Render the data in an HTML table                 $renderStr = "<table cellpadding=\"5\" border>                                 <tr>";                 foreach ($headings as $heading){                     $renderStr .= "<th>$heading</th>";                 }                 $renderStr .= "</tr>";                                  foreach ($submissionData as $submission){                     $renderStr .= "<tr>";                     foreach ($headings as $heading){                         $renderStr .= "<td align=\"center\">".$submission[$heading]."</td>";                     }                     $renderStr .= "</tr>";                 }                                  $renderStr .= "</table>";                 break;         }                  // Perform the actual rendering         echo $renderStr;              } else {         echo "No submissions exist for this event.";     } } ob_flush(); [/code]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.