不内联时,CSS样式表不工作

所以我试图将货币格式应用于HTML表格,以便在Excel中打开货币格式。 现在当我这样做内联,它可以正常工作,如下所示:

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

然而,我必须这样做几个领域,所以我想使它成为一个可重用的类。

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

像一个单元格:

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

这种方式行不通,对我而言,我不知道为什么。 任何人都可以帮助这个CSS新手?!

谢谢

@Limey:这两个在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> 

尝试更改“.cf {”到“td.cf {”

另外,你确定那里应该有一个美元符号吗? 因为根据此页面上显示的示例:

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

它看起来不像应该在那里。

我现在不能testing它,但你有没有尝试过:

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

或者也许你需要更多的斜杠#的?

我只是好奇,如果你能够在CSS文件中抛出无论何处,因为它通常保留为hex数字或注释。

也许这些链接会有帮助吗?

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