CSS stylesheet not working when not inline

So I'm trying to apply a currency format to an HTML table so that when I open it in excel, it has currency formatting. Now when I do this inline, it works fine, for example:

<td style="mso-number-format:$\##\,\##\##0\.00">=(sum(n4:n50))</td>

however, I have to do this with multiple fields, so I would like to make it a reusable class.

<style>

.cf{
 mso-number-format:$\##\,\##\##0\.00;
}
</style>

with cell type:

<td class="cf">=(sum(n4:n50))</td>

This method does not work, and for the life of me I do not know why. Can someone help this CSS newbie ?!

thank

+3
source share
3 answers

@Limey: both of these work for me in Excel 2003 -

<style type="text/css">
.cf1 {
    mso-number-format:$\##\,\##\##0\.00;
}
.cf2 {
    mso-number-format:"$\##\,\##\##0\.00";
}
</style>
<table cellspacing="0">
    <tr>
        <td class="cf1">500000</td>
    </tr>
    <tr>
        <td class="cf2">8000000</td>
    </tr>
</table>
+2
source

Try changing ".cf {" to "td.cf {"

, , ? , :

http://agoric.com/sources/software/htmltoExcel

, .

+1

I can't check this to be sure right now, but you tried:

.cf{
 mso-number-format:"$\##\,\##\##0\.00";
}

Or maybe you need more slashes for #s?

I'm just wondering if you can just drop #, anywhere, into the CSS file, as it is usually reserved for hexadecimal numbers or comments.

Perhaps these links would be useful?

http://jason-xge2.blogspot.com/

http://www.niallodoherty.com/post.cfm/basic-html-to-excel-formatting

http://www.dotnetspider.com/resources/23336-Exporting-Grid-view-or-data-Grid-Excel.aspx

0
source

Source: https://habr.com/ru/post/1786001/


All Articles