akaballa123
Technical User
hi,
I am trying to generate a mysql report in excel.
this is what I have currently:
Code:
<HTML>
<HEAD>
<TITLE>New Document</TITLE>
The problem is when this report generates in excel the output is shown in the following manner:
sessionID employeeName employeeID trainingName startDate endDate 12 Sriram 0 first 15.10.1988 12.12.1988 13 Sriram 0 first 10.12.2007 12.10.2007 14 Sriram Sampath 20223872 first 12/10/2008 12/25/2008 15 Sriram Sampath 0 first 12/12/1988 12/12/1988 16 Sriram Sampath 0 first 12/12/1988 12/12/1988 17 Sriram Sampath 0 first 12/12/1988 12/12/1988 18 Matt Duniigan 123456 first 12/10/1988 12/10/1988 19 Matt dungoen 123456 first 12/10/1988 12/10/1988 20 james 12321 first 12/10/1988 12/11/1999 21 Sriram Sampath 20223872 first 11/15/2001 11/12/2002 22 Sriram Sampath 20223872 first 12/11/2002 12/12/2003 23 testing 1234565 $value 12/12/1222 12/12/1222 24 testing2 1234321 first 01/02/1988 01/04/1999 25 123 123 G44 11/11/1111 11/11/1111
literally
it is not breaking the line in the correct area. Can someone please help me with this excel report generation. I am pretty new with this. Any information or recommendation would help. Thanks!!
Sriram Sampath
I am trying to generate a mysql report in excel.
this is what I have currently:
Code:
<HTML>
<HEAD>
<TITLE>New Document</TITLE>
Code:
<?php
include("mysqlConnection.php");
function Data(&$str)
{
$str = preg_replace("/\t/", "\\t", $str);
$str = preg_replace("/\n/", "\\n", $str);
}
// file name for download
$filename = "form_data_" . date('Ymd') . ".xls";
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Type: application/vnd.ms-excel");
$ticker = false;
$result = @mysql_query('SELECT * FROM sessiontbl') or die('Query failed!');
while(false != ($row = mysql_fetch_assoc($result)))
{
if(!$ticker)
{
# display field/column names as first row
echo implode("\t", array_keys($row)) . "\n";
echo "\n";
$ticker = true;
}
array_walk($row, 'Data');
echo implode("\t", array_values($row)) . "\n";
}
include("mysqlConnClose.php")
?>
</HEAD>
</HTML>
The problem is when this report generates in excel the output is shown in the following manner:
sessionID employeeName employeeID trainingName startDate endDate 12 Sriram 0 first 15.10.1988 12.12.1988 13 Sriram 0 first 10.12.2007 12.10.2007 14 Sriram Sampath 20223872 first 12/10/2008 12/25/2008 15 Sriram Sampath 0 first 12/12/1988 12/12/1988 16 Sriram Sampath 0 first 12/12/1988 12/12/1988 17 Sriram Sampath 0 first 12/12/1988 12/12/1988 18 Matt Duniigan 123456 first 12/10/1988 12/10/1988 19 Matt dungoen 123456 first 12/10/1988 12/10/1988 20 james 12321 first 12/10/1988 12/11/1999 21 Sriram Sampath 20223872 first 11/15/2001 11/12/2002 22 Sriram Sampath 20223872 first 12/11/2002 12/12/2003 23 testing 1234565 $value 12/12/1222 12/12/1222 24 testing2 1234321 first 01/02/1988 01/04/1999 25 123 123 G44 11/11/1111 11/11/1111
literally
it is not breaking the line in the correct area. Can someone please help me with this excel report generation. I am pretty new with this. Any information or recommendation would help. Thanks!!
Sriram Sampath