how to read from a xlsx file and out put to xml file

Topics: Developer Forum, User Forum
Nov 13, 2009 at 4:33 AM

what i wanna to do is read from a xlsx/xls file(no images) and save it into a xml file for future use. i am sure there is a way to do it, but just can't figure out what is the right way.

something like this

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'xml');


Nov 13, 2009 at 5:11 AM

Hmm... What kind of XML file are you talking about? PHPExcel does currently not have such writer.

Nov 13, 2009 at 9:09 AM

sorry, didn't explain myself very clear. here is my question

what i am try to do is using xlsx as a template, inside xlsx with some special characters, i would like use phpexcel read this template xlsx and replace all those characters with some real value.

i would do the replacing part now simple loop through all those cell and do replace, but when i am out puting new xlsx file, i am lossing all styles.

i am thinking if i can store all style into xml file then i can reuse them later on. or if there any other function that i can use to get styles.

hope this make more sence.

Nov 13, 2009 at 9:19 AM

>> but when i am out puting new xlsx file, i am lossing all styles.

You should be able to do a plain read/write of an xlsx file without losing styles. The idea sounds right.


$excel = PHPExcel_IOFactory::load('read.xls');

$worksheet = $excel->getActiveSheet()->getCell('A1')->setValue('hello');

$writer = PHPExcel_IOFactory::createWriter($excel, 'Excel2007');

Maybe you can post an example of what you tried.