Share this page 

Create an Excel fileTag(s): IO

While you can use specialized packages to create native Excel file, an easy way to import data into Excel is to create an HTML file and embed the date into a TABLE tag. You give to the file the XLS extension and Excel will do the translation for you!

With a text editor or from a program, create a file named test.xls with this content

<th><h4>Just testing</h4>
<TR><TD width="20">1</TD><TD width="30">2</TD><TD width="40">3</TD></TR>

Now you can double click on the saved file to load it into Excel and the translation will be done.

This trick works with OpenOffice too.

From a server, remember to send the appropriate MIME TYPE : application/excel to the client.

See also this HowTo