|
Posted by ajtrichards@googlemail.com on January 5, 2009, 10:18 am
Please log in for more thread options
Hi.
I've got the following code:
$file = "exported_data.xls";
require('../../Connections/mysql.php');
header("Content-Disposition: attachment; filename=\"".$file."\"");
header("Content-Type: application/excel");
flush();
$query = "SELECT * FROM scores WHERE month = '$month' AND year =
'$year' AND contract_id = '".$_SESSION['contract_id']."' ORDER BY
agentname, timestamp ASC";
$result= mysql_query($query);
$num = mysql_num_rows($result);
show/hide quoted text
?>
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
show/hide quoted text
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<Title>Monthly Monitoring Data Exported</Title>
<Author>Alex Richards</Author>
<LastAuthor>Alex Richards</LastAuthor>
<Created>2008-12-29T16:49:24Z</Created>
<Company>HIDDEN © <?php echo date('Y'); ?></Company>
<Version>12.00</Version>
</DocumentProperties>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<WindowHeight>11445</WindowHeight>
<WindowWidth>18975</WindowWidth>
<WindowTopX>120</WindowTopX>
<WindowTopY>75</WindowTopY>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11"
show/hide quoted text
ss:Color="#000000"/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID="s62">
<Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="8"
show/hide quoted text
ss:Color="#000000"/>
</Style>
<Style ss:ID="s63">
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous"
show/hide quoted text
ss:Weight="1"/>
</Borders>
<Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="9"
ss:Color="#000000"
show/hide quoted text
ss:Bold="1"/>
<Interior ss:Color="#D8D8D8" ss:Pattern="Solid"/>
</Style>
<Style ss:ID="s64">
<Alignment ss:Horizontal="Center" ss:Vertical="Bottom"
show/hide quoted text
ss:WrapText="1"/>
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous"
show/hide quoted text
ss:Weight="1"/>
</Borders>
<Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="9"
ss:Color="#000000"
show/hide quoted text
ss:Bold="1"/>
<Interior ss:Color="#D8D8D8" ss:Pattern="Solid"/>
</Style>
<Style ss:ID="s65">
<Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="8"
show/hide quoted text
ss:Color="#000000"/>
<NumberFormat ss:Format="Short Date"/>
</Style>
</Styles>
<Worksheet ss:Name="Exported Data">
<Table ss:ExpandedColumnCount="27" ss:ExpandedRowCount="<?php echo
show/hide quoted text
$num + 1; ?>" x:FullColumns="1"
x:FullRows="1" ss:StyleID="s62" ss:DefaultRowHeight="11.25">
<Column ss:StyleID="s62" ss:AutoFitWidth="0" ss:Width="96"/>
<Column ss:StyleID="s62" ss:AutoFitWidth="0" ss:Width="94.5"/>
<Column ss:Index="4" ss:StyleID="s62" ss:AutoFitWidth="0"
ss:Width="56.25"
show/hide quoted text
ss:Span="8"/>
<Column ss:Index="13" ss:StyleID="s62" ss:AutoFitWidth="0"
show/hide quoted text
ss:Width="59.25"/>
<Column ss:Index="15" ss:StyleID="s62" ss:AutoFitWidth="0"
show/hide quoted text
ss:Width="96"/>
<Column ss:Index="27" ss:StyleID="s62" ss:Width="69.75"/>
<Row ss:AutoFitHeight="0" ss:Height="36">
<Cell ss:StyleID="s63"><Data ss:Type="String">Agentname</Data></
Cell>
<Cell ss:StyleID="s63"><Data ss:Type="String">Monitored By</Data></
Cell>
<Cell ss:StyleID="s63"><Data ss:Type="String">Call Time</Data></
Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">Score: Question 1</
Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">Score: Question 2</
Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">Score: Question 3</
Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">Score: Question 4</
Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">Score: Question 5</
Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">Score: Question 6</
Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">Score: Question 7</
Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">Score: Question 8</
Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">Score: Question 9</
Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">Score: Question 10</
Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">Total Score</Data></
Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">Comments</Data></
Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">Input Date</Data></
Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">Call Date</Data></
Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">Call Reference</
Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">Call Number</Data></
Cell>
<Cell ss:StyleID="s63"><Data ss:Type="String">Day</Data></Cell>
<Cell ss:StyleID="s63"><Data ss:Type="String">Month</Data></Cell>
<Cell ss:StyleID="s63"><Data ss:Type="String">Year</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">Monitoring Type</
Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">Logged Into Call
Recording?</Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">Call In Compliance?</
Data></Cell>
<Cell ss:StyleID="s64"><Data ss:Type="String">Are You Happy with
Service?</Data></Cell>
<Cell ss:StyleID="s63"><Data ss:Type="String">UNIX Timestamp</
Data></Cell>
</Row>
<?php
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
show/hide quoted text
?>
show/hide quoted text
<Row ss:AutoFitHeight="0">
<Cell><Data ss:Type="String"><?php echo $row['agentname']; ?></
Data></Cell>
<Cell><Data ss:Type="String"><?php echo $row['coachname']; ?></
Data></Cell>
<Cell><Data ss:Type="String"><?php echo $row['calltime']; ?></
Data></Cell>
<Cell><Data ss:Type="Number"><?php echo $row['question01']; ?></
Data></Cell>
<Cell><Data ss:Type="Number"><?php echo $row['question02']; ?></
Data></Cell>
<Cell><Data ss:Type="Number"><?php echo $row['question03']; ?></
Data></Cell>
<Cell><Data ss:Type="Number"><?php echo $row['question04']; ?></
Data></Cell>
<Cell><Data ss:Type="Number"><?php echo $row['question05']; ?></
Data></Cell>
<Cell><Data ss:Type="Number"><?php echo $row['question06']; ?></
Data></Cell>
<Cell><Data ss:Type="Number"><?php echo $row['question07']; ?></
Data></Cell>
<Cell><Data ss:Type="Number"><?php echo $row['question08']; ?></
Data></Cell>
<Cell><Data ss:Type="Number"><?php echo $row['question09']; ?></
Data></Cell>
<Cell><Data ss:Type="Number"><?php echo $row['question10']; ?></
Data></Cell>
<Cell><Data ss:Type="Number"><?php echo $row['answer']; ?></Data></
Cell>
<Cell><Data ss:Type="String"><?php echo $row['comments']; ?></
Data></Cell>
<Cell><Data ss:Type="String"><?php echo date('Y-m-d', $row
['timestamp']); ?></Data></Cell>
<Cell><Data ss:Type="String"><?php echo $row['year'].'-'.$row
['month'].'-'.$row['day']; ?></Data></Cell>
<Cell><Data ss:Type="String"><?php echo $row['callref']; ?></
Data></Cell>
<Cell><Data ss:Type="String"><?php echo $row['callnum']; ?></
Data></Cell>
<Cell><Data ss:Type="Number"><?php echo $row['day']; ?></Data></
Cell>
<Cell><Data ss:Type="String"><?php echo $row['month']; ?></Data></
Cell>
<Cell><Data ss:Type="Number"><?php echo $row['year']; ?></Data></
Cell>
<Cell><Data ss:Type="String"><?php echo $row['remonitor']; ?></
Data></Cell>
<Cell><Data ss:Type="String"><?php echo $row['variable1']; ?></
Data></Cell>
<Cell><Data ss:Type="String"><?php echo $row['variable2']; ?></
Data></Cell>
<Cell><Data ss:Type="String"><?php echo $row['variable3']; ?></
Data></Cell>
<Cell><Data ss:Type="Number"><?php echo $row['timestamp']; ?></
Data></Cell>
</Row>
<?php
}
show/hide quoted text
?>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<PageSetup>
<Header x:Margin="0.3"/>
<Footer x:Margin="0.3"/>
<PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7"
show/hide quoted text
x:Top="0.75"/>
</PageSetup>
<Unsynced/>
<Print>
<ValidPrinterInfo/>
<PaperSizeIndex>9</PaperSizeIndex>
<VerticalResolution>0</VerticalResolution>
</Print>
<Selected/>
<Panes>
<Pane>
<Number>3</Number>
<ActiveRow>2</ActiveRow>
<RangeSelection>R3C1:R3C27</RangeSelection>
</Pane>
</Panes>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
</Workbook>
<?php
flush();
show/hide quoted text
?>
When I run this script using Firefox it works fine. The file gets
downloaded and MS Excel opens up. However, if I use Internet Explorer
I get a message saying:
"Internet Explorer cannot download export.php?month=12&year=2008 from
HOSTNAME.
Internet Explorer was not able to open this Internet site. The
requested site is either unavailable or cannot be found. Please try
again later."
The site is there and it is available!!!
Can anyone help me??
Best Regards,
Alex
|
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>