Sure, you'd output to the Excel XML spreadsheet format, which allows you to do colspans and such, although with a different syntax to HTML. (I posted this answer to the microsoft.public.xsl list the other day ;-)

The documentation is here :

Some Examples : and

But the easiest way by far is this :

Save your XML file in the desired format but choose "Save As", then
pick "XML Spreadsheet" as the file type to use (its in the same
dropdown as Lotus1-2-3 and CSV files).

Open the XML spreadsheet in a text editor and immediately you will see
how it is formatted. Now, ignore the HTML, and create an XML file
which matches the XML spreadsheet. Really you only need to generate
<Row> and <Cell> <Data> tags, the Style tags can be added to the XSLT
file. You can define almost any style used in excel such as borders, shading, number format (so no need to pre-convert numbers to currency for example_

Just use standard XSL to convert your XML data output from the DB to either of HTML or Excel spreadsheet (or even CSV for old Excel 97 !). I've done this in production environments and it works very very well indeed.

It should take about 2-3 hours the first time, and you'll make a
couple of mistakes. Examine the excel error log produced to find out
the error (the error log is saved in your temporary internet files).
It will be much fasted once you've tried it once.

From: "Perry, Matthew (Fire Marshal's Office)" <[EMAIL PROTECTED]>
Date: Mon, 29 Nov 2004 08:48:52 -0600
MIME-Version: 1.0
Content-Type: multipart/alternative;
Subject: Excel - merging cells with PHP

When you export a table to excel, is there a way to merge cells and create
borders?  I want my excel file to look exactly like my html table looks.

Matthew Perry

CaptionKit : Production tools
for accessible subtitled internet media, transcripts
and searchable video. Supports Real Player, Quicktime
and Windows Media Player.

VideoChat with friends online, get Freshly Toasted every
day at : NetMeeting solutions
for a connected world.

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to