I'm trying a trick I found on converting a report from generatated HTML
to an Excel spreadsheet.  Apparently there is a bug in MSIE that
requires that I use the following syntax to pass a link in order for the
headers to pick up on the fact that it is an Excel Spreadsheet that I'm after.

First page (test.html)


<excel_export.php/excel_export.xls">export to excel</a>



Second page (excel_export.php) in the same directory as test.html:

 
header("Content-Type:  application/vnd.ms-excel"); 
header("Expires: 0"); 
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 

include "DBinfo.php"; 

$connect = mssql_connect($host,$user,$pass) or die ($host." not
accessible."); 
if ($DB) mssql_select_db($DB)or die('USE '.$DB.' failed!'); 

$query = "SELECT last_name, first_name, nickname, division, title, id
FROM individual WHERE last_name LIKE'A%'"; 
$result = mssql_query($query); 
$numRows = mssql_num_rows($result); 

echo"<table>"; 
for($i=0; $i<$numRows; $i++){   
        echo "<tr>"; 
                $row = mssql_fetch_array($result); 
echo " 
<tr> 
<td valign='top' align='left'>$row[last_name]</td> 
<td valign='top' align='left'>$row[first_name]</td> 
<td valign='top' align='left'>$row[division]</td> 
<td valign='top' align='left'>$row[title]</td> 
</tr>"; 
} 
echo "</table>"; 

?>






The error I keep getting is:


page 1: 
<excel_export.php/excel_export.xls">export to excel</a> 

page 2: 

<? 
header("Content-Type:  application/vnd.ms-excel"); 
header("Expires: 0"); 
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 

include "DBinfo.php"; 

$connect = mssql_connect($host,$user,$pass) or die ($host." not
accessible."); 
if ($DB) mssql_select_db($DB)or die('USE '.$DB.' failed!'); 

$query = "SELECT last_name, first_name, nickname, division, title, id
FROM individual WHERE last_name LIKE'A%'"; 
$result = mssql_query($query); 
$numRows = mssql_num_rows($result); 

echo"<table>"; 
for($i=0; $i<$numRows; $i++){   
        echo "<tr>"; 
                $row = mssql_fetch_array($result); 
echo " 
<tr> 
<td valign='top' align='left'>$row[last_name]</td> 
<td valign='top' align='left'>$row[first_name]</td> 
<td valign='top' align='left'>$row[division]</td> 
<td valign='top' align='left'>$row[title]</td> 
</tr>"; 
} 
echo "</table>"; 

?> 


The error I keep getting is:

CGI Error 
The specified CGI application misbehaved by not returning a complete set
of HTTP headers. The headers it did return are:



Am I doing something incorrectly?  

Ron

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to