There is a topic about it at http://www.daniweb.com/forums/showthread.php?t=91019&highlight=excel
It basically says to use the excel html formating like when you export html file from excel. Also it quotes the following code:
<?php
echo "<table cellspacing='4' cellpadding='4' border=1 align=center>";
echo"<tr>";
echo"<td>Day</td>";
echo"<td>Time</td>";
echo"<td>Unit</td>";
echo"<td>Lecturer</td>";
echo"</tr>";
echo"</table>";
header("Content-type: application/octet-stream");
# replace excelfile.xls with whatever you want the filename to default to
header("Content-Disposition: attachment; filename=excelfile.xls");
header("Pragma: no-cache");
header("Expires: 0");
?>
</p>
</body>
</html>
Hope that helps.
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
Well I don't know you database structure (column names) but first step is to make the data output like the below. After you make a php file with the output like the below, then I shall show you how to add the headers to download as a excel file. The headers are also shown in the example above (previous post).
<table cellspacing='4' cellpadding='4' border=1 align=center>
<tr>
<td>Date</td>
<td>Day</td>
<td>TimeIn</td>
<td>TimeOut</td>
<td>TotalTime</td>
<td>Status</td>
</tr>
<tr>
<td>2009-02-23</td>
<td>Monday</td>
<td>10:11:18</td>
<td>19:38:22</td>
<td>9.27 Hours</td>
<td>O.K.</td>
</tr>
<tr>
<td>2009-02-24</td>
<td>Tuesday</td>
<td>10:09:52</td>
<td>20:06:27</td>
<td>9.56 Hours</td>
<td>O.K.</td>
</tr>
<tr>
<td>2009-02-25</td>
<td>Wednesday</td>
<td>10:04:13</td>
<td>18:52:28</td>
<td>8.49 Hours</td>
<td>O.K.</td>
</tr>
<tr>
<td>2009-02-26</td>
<td>Thursday</td>
<td>09:56:55</td>
<td>19:52:56</td>
<td>9.56 Hours</td>
<td>O.K.</td>
</tr>
<tr>
<td>2009-02-27</td>
<td>Friday</td>
<td>10:08:51</td>
<td>18:00:00</td>
<td>09 Hours</td>
<td>O.K.</td>
</tr>
<tr>
<td>2009-02-28</td>
<td>Saturday</td>
<td>10:06:13</td>
<td>19:50:34</td>
<td>9.44 Hours</td>
<td>O.K.</td>
</tr>
</table>
Just a note, I noticed the link I provided didn't work so the update is: http://www.daniweb.com/forums/thread91019.html
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
//while clicking download button do this process
$content - should have the content like
$content = "val1val2";
header('Pragma: anytextexeptno-cache', true);
header("Content-type: application/vnd.ms-excel");
header('Content-Transfer-Encoding: Binary');
header('Content-disposition: attachment; filename='myfile.xls');
print $content;
You have that backtofront. Unusally it is more like the following as quoted from an earlier post:
<?
$content - should have the content like
$content = "<table><tr><td>val1</td><td>val2</td></tr></table>";
echo $content;
header('Pragma: anytextexeptno-cache', true);
header("Content-type: application/vnd.ms-excel");
header('Content-Transfer-Encoding: Binary');
header('Content-disposition: attachment; filename=myfile.xls');
?>
</p>
</body>
</html>
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
Hi vinoth,
I want to discuss with you . because i am facing one problem which i have already discussed in this forum session_start warning . please help me . i have done every effort for solving that warning.
pls help me if u can solve this.
thanks ,
gagan
Did you check my post on http://www.daniweb.com/forums/thread177977.html
I have found numerous topics on both daniwebs and PHPfreaks in the past and two main reasons are the editor adds a hidden string at the beginning and the second being that there is something before <? tag. I believe some have even tried using <?php instead of <? or vice versa and is then successful.
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
thanks for reply,
I have also tried this as u told me. I have changed the <? tag to <?php also .Still the problem is same . pls help me . how i can solve this.
thanks,
Try making a file using your normal editor and type the following code in it to see if it reports an error.
<?
session_start();
?>
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
Also I still haven't heard of the results for when you try to open a page with only the following code:
<?
session_start();
?>
That will say if it is your editor.
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259