求助:导出EXCEL,数字显示为字符串型,怎么才能导出为数字型?(附代码)
代码如下:
protected void Button1_Click(object sender, EventArgs e)
{
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=file.xls");
Response.Charset = "GB2312";
Response.ContentEncoding = Encoding.UTF8;
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
Page.EnableViewState = false;
rptDelivList.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
}
------解决方案--------------------数字默认就是数字类型 。除非你使用了字符串的样式。
你看看你的绑定中有没有用到mso-number-format之类的样式
------解决方案--------------------将你的数据源里的这些字段设置为int类型的试试.
------解决方案--------------------把灰色那行去掉,导出来下面的也跟着是数字了。
------解决方案--------------------http://blog.csdn.net/jinjazz/archive/2008/08/01/2753869.aspx
http://blog.csdn.net/jinjazz/archive/2008/08/04/2766203.aspx