title: Convert HTML to Excel Rich Text and vice versa
body: <p>I'm using <a href="http://www.phpexcel.net" rel="nofollow">PHPExcel</a> for transferring data between MySQL DB and Excel  2007 worksheets. It works well on most situations, but I encountered one problem. </p>
  
  <p>Some of the fields in DB contain HTML data. I need to preserve the formatting in Excel cells as much as possible. As I could figure out, Excel allows the following formatting inside cells (<code>PHPExcel_RichText</code> class supports all of these): new lines [these can be used to track <code>&lt;p&gt;&lt;/p&gt;</code> blocks], font name, size, color, bold, italic, underline, strikethrough, subscript, superscript. Suppose these are enough, so we can ignore other HTML formatting.</p>
  
  <p>What is the best (easiest, fastest) way to convert HTML data to Excel Rich Text and vice versa? </p>
  
  <p>One solution I've in mind is to create a function that will traverse the HTML [using <code>DOMDocument</code> or so], place <code>\n</code> after block elements, create <code>PHPExcel_RichText_Run</code> objects for <code>&lt;b&gt;</code>, <code>&lt;i&gt;</code> etc, and ignore all other elements. I feel this will be quite "expensive", especially when dealing with nested structures, like <code>&lt;b&gt;some &lt;i&gt;formatted&lt;i&gt; text&lt;/b&gt;</code> </p>
  
  <p>Is there any better way to do this, with or without <code>PHPExcel</code>? </p>
  
  <p>One more idea: I noticed that when exporting in <em>XML Spreadsheet 2003</em> format the following appears inside XML:</p>
  
  <pre><code>&lt;ss:Data ss:Type="String"
    xmlns="http://www.w3.org/TR/REC-html40"&gt;&lt;Font html:Color="#000000"&gt;this is &lt;/Font&gt;&lt;B&gt;&lt;Font
      html:Color="#000000"&gt;some &lt;/Font&gt;&lt;I&gt;&lt;Font html:Color="#000000"&gt;formatted&lt;/Font&gt;&lt;/I&gt;&lt;Font
      html:Color="#000000"&gt; text&lt;/Font&gt;&lt;/B&gt;&lt;/ss:Data&gt;
  </code></pre>
  
  <p>which is normal HTML4. I mean it seems that Excel <strong>can</strong> understand plain HTML. So maybe there is some way to pass HTML directly to Excel without converting it to <code>PHPExcel_RichText</code> objects... (although note that it would be best if I'll be able to export to .xlsx format)</p>