gotqn gotqn - 29 days ago 17
HTML Question

MS Excel display HTML table with colors?

Is there a way the MS Excel to open not only my HTML but to show and the colors? I have tried with style,font and color tag and nothing have worked.

Answer

If the data is actually an HTML page and has NOT been created by ASP, PHP, or some other scripting language:

Open Internet Explorer, simply right-click on the table and look through the menu. You should see "Export to Microsoft Excel." Click on the menu item and after a few prompts it will be imported to Excel.

If the data is made using any scripting language:

Here is a simple way to export an HTML table to Excel with a single line of code. For the technique to work, you must have Excel installed on the your machine. Copy the following code and paste it in notepad. Save it as an ASP page, and then open it in the browser to see the action live.

Note: Do not forget to paste the code of the table you will get by viewing the source of the html file you wish to convert to excel

<% The main feature of this technique is that %>
<% you have to change Content type to ms-excel.%>
Response.ContentType = "application/vnd.ms-excel"
<TABLE>
<TR><TD>2</TD></TR>
<TR><TD>3</TD></TR>
<TR><TD>=SUM(A1:A2)</TD></TR>
</TABLE>

Don't include normal HTML, TITLE, HEAD, and BODY tags. They will create a problem.

EDIT:

For copying colours if you have the html table:

Just copy the full static table to word and then copy it again from word, then right click on desired excel cell and click on "Paste Special"

Comments