Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Supported Html elements by Excel

Tags:

html

excel

Recently I found out that if you save some html markup as an xls it will open up in Excel just fine with all your styling. Example

myfile.xls

<table>
        <tr>
            <td style="background: red;text-align:center;border:1px solid;"><h1>Blah</h1></td>
            <td style="background: red;text-align:left;font-weight:bold;">Blah</td>
        </tr>
        <tr>
            <td>3221312dsdasd</td>
            <td>hahah2123dedaah</td>
        </tr>
        <tr>
            <td>123456</td>
            <td>hahah2123dedaah</td>
        </tr>
</table>

I was wondering if there is any kind of documentation on this about what html and CSS Excel supports and what it doesn't? I tried using Google and really couldn't find much. I was mostly interested in creating multiple worksheets.

like image 227
Danny Avatar asked Oct 24 '11 21:10

Danny


People also ask

Does Excel support HTML?

MS Excel cannot properly render HTML inside cells. It can render simple formatting like bold text and colors, but it cannot render paragraphs, pictures, tables, links, and rich formatting in general in a single cell.

Can Excel convert HTML to text?

So there are two ways to convert html to text in Excel. One is using the Find and Replace feature. The Find and Replace feature in Excel finds the character you specify and replaces it with any text, character, or number you input. Another way is using VBA in Excel.


1 Answers

For some in-depth information regarding the HTML approach to creating Excel files with sample code see http://www.c-sharpcorner.com/UploadFile/kaushikborah28/79Nick08302007171404PM/79Nick.aspx

Also checkout the official documentation at http://msdn.microsoft.com/en-us/library/Aa155477%28office.10%29.aspx

Other options to create Excel files:

MS provides the OpenXML SDK V 2.0 - see http://msdn.microsoft.com/en-us/library/bb448854%28office.14%29.aspx

This can read+write MS Office files (including Excel).

Another option see http://www.codeproject.com/KB/office/OpenXML.aspx

IF you need more like rendering, formulas etc. then there are different free and commercial libraries like ClosedXML, EPPlus, Aspose.Cells, SpreadsheetGear, LibXL and Flexcel etc.

like image 58
Yahia Avatar answered Oct 09 '22 19:10

Yahia