0

Is there a way to convert .xml file to .xls using php code?

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

2

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.