Linux Hosting
NT/2000 Hosting
DYO Internet Access
HTMLez.com
JAVASCRIPTez.com
ASPez.com

Select a Domain
    

It's easy to use HTML to create an Excel .xls readable file... The php code must create just an HTML table without the HTML tag, the HEAD tag, and without the BODY tag. Echo the <table> tag, the <tr> tags to delimit rows and <td> tags to delimit columns, the values within the <td> tags, and end with </table>. You can also echo functions within a table cell. Below is a simple example to get you started.

<?php

Header("Content-type: application/vnd.ms-excel");
/* Note: the table below would probably be created
by extracting values from a database or file or
by retrieving them from form fields. For simplicity
we merely create the table hardcoded without the
php processing and echo statements. */
?> <table> <tr><td colspan="2">Absences for the Week</td></tr> <tr><td>Day of Week</td><td>Number of Absences</td></tr> <tr><td>Monday</td><td>1</td></tr> <tr><td>Tuesday</td><td>2</td></tr> <tr><td>Wednesday</td><td>3</td></tr> <tr><td>Thursday</td><td>4</td></tr> <tr><td>Friday</td><td>5</td></tr> <tr><td>Total Absences</td><td>=sum(b3:b7)</td></tr> <tr><td>Average Absences</td><td>=average(b3:b7)</td></tr> </table> Simply save this (without html/head/body) as a .php3 or .php4 file. The browser may prompt you to save or to load the file. Select load and if you have Microsoft Excel on your machine you'll soon see a real spreadsheet. Note that you may find you want a header row as found in the example since otherwise you may have to manual expand each column of cells which by default seem to display for a width matching only your largest numberic size although the SUM or other function may need more digits to display the result. If you also have a website assisting web authors, please feel free to link to either this page or to link to PHPez.com. If you would like to contribute code to any of the EZ pages referenced on the left, Please email me here. You may also email me if you would like to exchange links (compatible sites only).

cover
cover

cover
cover

PHP Copyright Notice