views:

425

answers:

2

INTRODUCTION

I'm using excel downloads as a way of users downloading a score sheet, filling out scores and then re-uploading this score sheet into the system.

Part of this requires the data in the database to be put into a CSV. Then its opened on the client computer.

PROBLEM

The problem I'm having is that the CSV does not allow me to use any kind of formatting. This includes hiding cells, making text bold etc.

So parsing the data in and out of an excel format (xls) document would make more sense... But from what I've heard and read, this would be really difficult because of different excel versions etc etc.

QUESTION

I heard that XML is a good way of parsing data into an excel format. I wondered if anyone had any experience of this using php?

Is there a good script anyone has heard of? Does anyone have any comments on different versions of excel opening ir (or even, things like open office or lotus) What do you think if my best step forward?

Thanks very much for your help! Either reply or email me tom at candid sky dot com

A: 

I'm sure there are, for example, Perl modules which would help with XML, but consider also that an HTML table: <tr>, <td>, <th> tags will be opened by Excel and at least some of the formatting will translate to Excel

you just have to name it ... something.xls

pavium
Plus you have to send headers so Excel open the document.
mere-teresa
Apparently not - I generate the pseudo-xls file containing an HTML table, and nothing else; save it in a folder on a Windows file system, and Excel can open it as if it was a genuine Excel file.
pavium
Could I produce an excel spread sheet, save it as an xml file... then use this as a template to create a parser?I'm just not sure how to extract the data from in between the fields (ie the parsing bit) - Any ideas? (I'm intermediate at php)
Tom
@pavium : you're right, I was thinking about force download. Sorry
mere-teresa
+3  A: 

Try out PHP Excel (not sure if both links are the same) and PHP Excel Reader.

Alix Axel
These are great, but they seem a little heavy. Is there no small parser function that I could pull out?Thanks for your helpTom
Tom
Hi Tom, sorry those are the only Excel libraries for PHP that I know of, maybe you can try out COM objects, not sure if they fit your needs though.
Alix Axel
Thanks this just saved me a ton of work :)
Phill Pafford