RE : Subject: Excel - merging cells with PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 :

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnexcl2k2/html/odc_xmlss.asp

Some Examples :

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnoffpro01/html/XMLOfficeXPPartI.asp
http://www.simonstl.com/articles/officeXML/spreadsheetML.html and
http://www.simonstl.com/articles/officeXML/spreadsheetMLsample.html

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.

Message-ID: <9EEDF0D0C8B3574B9B75503A0F0620E605843C84@xxxxxxxxxxxxxxxxxxxxxx>
From: "Perry, Matthew (Fire Marshal's Office)" <Matthew.Perry@xxxxxxxxxxxx>
To: php-db@xxxxxxxxxxxxx
Date: Mon, 29 Nov 2004 08:48:52 -0600
MIME-Version: 1.0
Content-Type: multipart/alternative;
 boundary="----_=_NextPart_001_01C4D622.8B3E44C4"
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 http://www.captionkit.com : 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 http://www.fresh-toast.net : NetMeeting solutions
for a connected world.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux