开发者

css style sheet not working when not inline

So I am 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, like so:

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

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

<style>

.cf{
 mso-number-format:$\#开发者_运维百科#\,\##\##0\.00;
}
</style>

with a cell like:

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

This way doesn't work, and for the life of me, I don't know why. Can anybody help out this CSS newbie?!

Thanks


@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>


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

Also, are you sure there should be a dollar sign there? Because according to the examples shown on this page:

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

It doesn't look like it should be there.


I can't test it to be sure right now but have you tried:

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

Or perhaps you need more slashes for the #s?

I'm just curious if you're able to just throw # wherever you please in a CSS file since it's usually reserved for hex numbers or comments.

Maybe these links would be helpful?

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜