views:

168

answers:

2

I would like to use XSL to create excel .xml files that Excel 2003 can open. Does anyone know of a XSL template library that I can use for the purpose?

+2  A: 

There cannot be any one generic XSLT stylesheet that can do this task since the source data can be designed in any strange way possible.

The best approach that you can take at this time is to get to know the Schema's for Excel 2003's XML Format - link given below - and write an XSLT which would generate that XML.

While this could be a complicated and erroneous approach, an easier approach would be to have a look at your source XML data, then creating the Excel sheet manually with all the formatting that you intend to do with that information, and then save it as XML. Open this in a text editor to get an idea of how the XML looks and write an XSLT which would convert your source XML to this resultant XML.

Again as I said, since the formatting could be anything that you could want and the source xml can be anything - a generic stylesheet simply cannot be designed (Unless it is only columns of data for which some source xml standard is already there - which I may not be aware of)

PS:- If I remember correctly from my experience with Excel XML, there was some node or attribute where you had to specify the total number of rows and total number of columns, which if wrong would make it complain when you open the file.

Hope this helps.

Thiyagaraj
I would have to endorse this as a general approach - I've found the most successful way (usually) to get XSLT to generate the right output is to start with a good example or two and work backwards from there (use the most complete example to work from and test against alternative examples).
Murph
That was what I did in the first place, but I wanted to see if anyone had abstracted some of the boilerplate away into a set of templates. Thanks for the help!
Matthew Sowders
+1  A: 

This may be too simple for your needs, but you can always output a tab- or comma-delimited text file using XSLT, which Excel will open nicely.

carillonator
For a certain subset of problems this would be by far the easiest method. You'll have to determine if it meets your needs.
Jim Garrison
No, I need to have separate sheets, and this cannot be done with delimited files.
Matthew Sowders