Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML Table to XLS (Cell used for a formula)

I am doing an HTML table and I want it to be converted to XLS file

I am using this table for example

<table>
    <tr>
        <td>AUD</td>
        <td>200.00</td>
    </tr>
    <tr>
        <td>AUD</td>
        <td>200.00</td>
    </tr>
    <tr>
        <td>AUD</td>
        <td>200.00</td>
    </tr>
    <tr>
        <td>EUR</td>
        <td>300.00</td>
    </tr>
    <tr>
        <td>AUD</td>
        <td>200.00</td>
    </tr>
    <tr>
        <td>AUD</td>
        <td>200.00</td>
    </tr>
    <tr>
        <td>AUD</td>
        <td>200.00</td>
    </tr>
    <tr>
        <td>AUD</td>
        <td>**=SUM(A2:A10);**</td>
    </tr>
</table>

Is there a way how I can create a cell with the =SUM(A2:A10); as a formula and not a normal plain text?

like image 308
BoqBoq Avatar asked Dec 28 '22 20:12

BoqBoq


2 Answers

When importing html to excel, it is important to know that there are a variety of excel-specific attributes that you can use to get excel to perform pretty much like you would expect it to, for nearly any business requirement.

You'll need the excel namespaces added:

<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">
</html>

And then you can create a formula in a table cell:

<td x:num x:fmla="=SUM(A2,A10)">0</td>

You can read much more about properly implementing these capabilities in this article: http://www.c-sharpcorner.com/UploadFile/kaushikborah28/79Nick08302007171404PM/79Nick.aspx

like image 91
Kevin Vaughan Avatar answered Dec 30 '22 11:12

Kevin Vaughan


This works for me:

replace

<tr>
<td>AUD</td><td>**=SUM(A2:A10);**</td>
</tr>

with

<tr>
<td>AUD</td><td>=SUM(A2:A10)</td>
</tr>
like image 28
chris neilsen Avatar answered Dec 30 '22 11:12

chris neilsen