HTML到Excel:怎样才能让Excel将列视为数字? [英] HTML to Excel: How can tell Excel to treat columns as numbers?

查看:176
本文介绍了HTML到Excel:怎样才能让Excel将列视为数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Excel中打开HTML时需要实现以下功能(Response.contentType =application / vnd.ms-excel)

I need to achieve the following when opening an HTML in Excel (Response.contentType="application/vnd.ms-excel") :


  • 强制Excel考虑td单元格的内容作为数字

  • 使上述内容使任何后续用户输入的公式工作这些单元格(打开电子表格时)

到目前为止,我成功添加了 style =vnd。 ms-excel.numberformat:0.00到有问题的td单元格。当我在Excel中右键单击它们时,单元格的内容将被正确显示为数字,但是公式不起作用。

So far I was successful with adding style="vnd.ms-excel.numberformat:0.00" to the td cells in question. The contents of the cells are correctly shown as numbers when I right click on them in the Excel, however the formulas don't work.

如果成功,该技术将是非常有用,因为任何Web Excel报表都可以根据自定义要求用适当的公式进行用户增强。谢谢提前。

If successful, that technique would be quite useful because any web Excel report could be user enhanced with appropriate formulas according to custom requirements. Thanks in advance.

推荐答案

如果您添加一个CSS类到您的页面:

If you add a CSS Class to your page:

.num {
  mso-number-format:General;
}
.date {
  mso-number-format:"Short Date";
}

在TD上拍下这些类,它是否正常工作?

And slap those classes on your TD's, does it work?

<td class="num">34</td>
<td class="num">17.0</td>
<td class="date">12/17/2008</td> <!-- if you are playing with dates too -->

更新: 其他格式选项

这篇关于HTML到Excel:怎样才能让Excel将列视为数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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