导出到excel,数字问题 [英] export to excel, number problem

查看:418
本文介绍了导出到excel,数字问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

StringWriter strWriter = new StringWriter();
HtmlTextWriter htmlWriter = new HtmlTextWriter(strWriter);

Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=excel.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";





i使用上面的代码将我的gridview转换为excel,一切都很好,除了一个包含多达12个数字的字段。

它们在gridview中看起来很好,在转换为excel后,它变成:



i used above code to convert my gridview to excel, everything is good except one field which contains up to 12 numbers.
they look good in gridview, after convert to excel, it became:

   Gridview        Excel
860201231356 to 8.60201E+11
123456121115 to 1.23456E+11
123456120010 to 1.23456E+11



i需手动

1.更改格式从文本到数字

2.按减少十进制删除.00



如果无论如何要解决这个问题?


i need to manually
1. Change the format from text to number
2. Press "Decrease decimal" to remove the ".00"

if there anyway to solve this?

推荐答案

我认为你必须为此使用Interop,因为它为在Excel中定义单元格类型提供了更大的灵活性:

http://support.microsoft.com/kb/302084 [ ^ ]



我不认为可以使用其他技术,但它们可能是......
I think you will have to result to using Interop for this, as it gives much more flexibility to define the cell type in Excel:
http://support.microsoft.com/kb/302084[^]

I dont think it is possible using other techniques but they might be..


这篇关于导出到excel,数字问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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