Convert HTML to Rich Text

Topics: Developer Forum, User Forum
Mar 5, 2011 at 6:53 AM

Hi all,

I have some cell data in HTML format that I'd like to convert to XLS. I'm already using PHPExcel to create file spreadsheets, but I currently strip the tags of any HTML values in my spreadsheet. Instead, I'd like to parse the HTML and convert it to Rich Text runs.

Does PHPExcel contain such code? Otherwise, can anyone suggest a starting point (short of writing from scratch)?

TIA,

Karim

Mar 7, 2011 at 7:49 PM

I ended up subclassing TCPDF in PHPExcel/Shared/PDF/tcdpf.php which contains a lot of useful code to parse HTML and CSS. The method TCPDF::getHtmlDomArray is useful to convert the HTML fragment to an array that can then be iterated to create the rich text runs.