I am using PHPExcel to extract data from my database onto an organized Excel sheet. Everything is working great except for one thing. My database entries can sometimes contain HTML markups like
<p></p> etc ... So I managed to get this PHP line working, this is working great to replace my
<BR> markups to a space.
$data = str_replace("<br />", "n", $data); $data = str_replace("<br/>", "n", $data); $data = str_replace("<br>", "n", $data);
However when I try doing the following it does nothing. I was expecting that it would bold the text.
$data = str_replace("<strong>", '&B', $data);
I read on these forums that its best to use preg_replace and setup an array for all the HTML markups I need replaced. For the life of me I can't understand how to use preg_replace. Would someone please give me some advise what is the best way to replace markups such as
</strong> to bold when it exports, this would be very much appreciated.
'&B'will only set bold text for printed page headers and footers, as described in the section of the documentation entitled
Setting the print header and footer of a worksheet
Formatting the content of a cell is described in the section of the documentation entitled
Formatting cells, something like:
or (if your content contains actual markup) using Rich Text objects if you only want to set part of the text to bold.
but you will need to parse your markup to convert it to a Rich Text object