使用Excel 2013的HTML和自定义格式的货币 [英] Using html for excel 2013 with Custom format for currency

查看:104
本文介绍了使用Excel 2013的HTML和自定义格式的货币的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用HTML将网站中的数据导出到excel.

I am exporting data from my site to excel, using HTML.

对于货币,我正在使用以下课程:

For currency, i am using the following class:

.DDD {
            mso-number-format: '\0022$\0022\#\,\#\#0\.00';
        }

当我在excel 2007-2010中打开它时,行为正常. (我看到了带有货币的数字,但是当我编辑单元格时,您可以看到它是一个数字-因此您可以在其上使用Sum()之类的函数) 但是,当我在excel 2013中打开它时,我无法使用函数,并且看到单元格值为"$ 10.00"(而不是10.00)-因此它不是数字.

When I open it in excel 2007-2010 the behavior is OK. (i see the number with the currency, but when i edit the cell, you can see it is a number - so you can use function like Sum() on it) BUT when I open it in excel 2013 I can't use functions, and I see the cell value is "$10.00" (and not 10.00) - so it is NOT a number.

在此示例中,我使用"$",实际货币为NIS(₪")

I'm using "$" just for this example, the actual currency is NIS ("₪")

有没有一种方法可以使它适用于所有优秀软件?

Is there a way to make it work for all excels?

我相关的HTML是:

<table>
 <tr>
  <td class="DDD">
    <span>$</span>
    <span>1234.56</span>
  </td>
 <tr>
</table>

最终,我删除了货币跨度,并且在所有excel上都可以正常工作.

Eventually I removed the span with the currency, and it works fine on all excels.

推荐答案

能否请您为此CSS显示HTML?

因为我有:

<meta http-equiv="content-type" content="application/vnd.ms-excel; charset=UTF-8">

<style>
.DDD {
 mso-number-format:"\0022₪\0022\#,\#\#0\.00";
}
</style>

<table>
 <tr>
  <td class="DDD">1234.56</td>
 <tr>
</table>

然后Excel看起来像:

then the Excel looks like:

在Excel 2016中.这是德语Excel.所以1234,56是一个数字.

in Excel 2016. This is a German Excel. So 1234,56 is a number.

我认为Excel 2013与此没有太大的不同.

I don't believe that Excel 2013 is as much different with this.

如果还需要在浏览器视图中使用该格式,那么您可以:

If the need is also to have the format in browser view, then you could have:

<meta http-equiv="content-type" content="application/vnd.ms-excel; charset=UTF-8">

<style>
.DDD {
 mso-number-format: "\0022₪\0022#,##0.00";
 font-size: 2em;
}
.DDD::before {
 content: "₪";
}
.DDD .thousand::before {
 content: ",";
}
</style>

<table>
 <tr>
  <td class="DDD">1<span class="thousand">234</span>.56</td>
 <tr>
</table>

但是更好的方法是将视图要求与数据导出要求严格分开.因此要具有不同的视图和数据导出格式.综上考虑,不是直接使用HTML进行数据导出,而是直接使用XML或更好的格式(在这种情况下为Excel)

But better approach will be, strictly separate view requirements from data export requirements. So to have different formats for view and data export. And in conclusion of all considerations, not to use HTML for data export but XML or better the needed format - Excel in this case - directly.

这篇关于使用Excel 2013的HTML和自定义格式的货币的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆