Php code to convert .xml to .xls(Basically from xmlExcel to Excel spreadsheet)
Is there a 开发者_运维百科way to convert .xml file to .xls using php code?
1) Read in the XML file using [simplexml_load_file()][1]
2) Loop through each XML element representing one line item in the XLS file
3) Use [fputcsv()][2]
to create a comma separated file with the data from step 2
4) Save the file with a .csv extension and it will open in excel.
If you want to create an Excel spreadsheet I think you need to work with COM objects. Not my forté so I can't help you with that.
Dunno about converting XML to XSL, but in the book PHP Hacks there is a hack for generating excel spreadsheets most of which is available on Google Books, in its chapter on XML no less!
So that would be a good place to start looking if nobody's got the answer here.
精彩评论