php - Export to excel file give a warning message when try to open it -
could help me on how remove warning when export excel using php.
the file trying open "example.xls in different format specified file extension.
here code , please specify doing wrong
<?php // start session session_start(); // define variables $_session , $_get $firstname = $_session['firstname']; $lastname = $_session['lastname']; $username = $_session['username']; $start = $_get['start']; $end = $_get['end']; $providerid = $_get['providerid']; $summarytype = $_get['summarytype']; $subspeciality = $_get['subspeciality']; $export = $_get['export']; // connect mysql db include ("access.php"); header("content-type: application/vnd.ms-excel; name='excel'"); header("content-disposition: filename=export.xls"); // prepare crappy ie bug in download. header("pragma: "); header("cache-control: "); error_reporting("e_all"); $sql = "select *, master.emtracsigchange 'sigchange' master, nightrad master.emtracsigchange='yes' , master.marygrade!='' , master.internalexamid=nightrad.internalexamid , master.transcriptiondttm <= '$end' , master.transcriptiondttm >= '$start'"; $result = mysql_db_query('testdb',$sql); if(!$result) { echo "<p>no matches query</p>"; echo "<p>click on browser alter query parameters.</p>"; die(mysql_error()); } ?> <html> <head></head> <body> <table border="1" cellspacing="0" cellpadding="3"> <tr> <th bgcolor="#0099ff" scope="col">accession</th> <th bgcolor="#0099ff" scope="col">transcribed</th> <th bgcolor="#0099ff" scope="col">turnaround time</th> <th bgcolor="#0099ff" scope="col">attending</th> <th bgcolor="#0099ff" scope="col">res or fellow</th> <th bgcolor="#0099ff" scope="col">modality</th> <th bgcolor="#0099ff" scope="col">exam</th> <th bgcolor="#0099ff" scope="col">discrepancy</th> <th bgcolor="#0099ff" scope="col">folder</th> <th bgcolor="#0099ff" scope="col">comment</th> </tr> <?php // add together values in table $out. while ($row = mysql_fetch_assoc($result)) { $completeddttm = $row['completeddttm']; $transcriptiondttm = $row['transcriptiondttm']; $date = date("y-m-d", strtotime($transcriptiondttm)); // converting turnaround time dttm time $parsedtime = strtotime($completeddttm . " gmt"); $convertedtime = gmdate("h:i:s", $parsedtime); $parsedtime1 = strtotime($transcriptiondttm . " gmt"); $convertedtime1 = gmdate("h:i:s", $parsedtime1); $parsedtat = $parsedtime1 - $parsedtime; $turnaroundtime = gmdate("h:i", $parsedtat); ?> <tr > <td><?php echo $row['accessionnumber']; ?></td> <td><?php echo $date; ?></td> <td><?php echo $turnaroundtime; ?></td> <td><?php echo $row['attendinglastname']; ?></td> <td><?php echo $row['lastname']; ?></td> <td><?php echo $row['modality']; ?></td> <td><?php echo $row['examdesc']; ?></td> <td><?php echo $row['marygrade']; ?></td> <td><?php echo $row['maryfolder']; ?></td> <td><?php echo $row['marycomment'] ?></td> </tr> <?php } ?> </table> </body> </html>
it gives me info issue when seek open shows warning message also.please help
looks outputting html excel file. suggest utilize fputcsv function output csv value. , utilize next content-type:
header('content-type: text/csv; charset=utf-8'); header('content-disposition: attachment; filename= export.csv');
php excel export
No comments:
Post a Comment