首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

[]gridview导出之后身份证号是科学计数法

2012-03-25 
[求救]gridview导出之后身份证号是科学计数法gridview导出之后身份证号是科学计数法,显示之后数据最后几位

[求救]gridview导出之后身份证号是科学计数法
gridview导出之后身份证号是科学计数法,显示之后数据最后几位全是0了。找了半天,改不对啊!!

C# code
    private void Export(string FileName)    {        Response.Clear();        Response.Buffer = true;        Response.Charset = "GB2312";        Response.ContentEncoding = System.Text.Encoding.UTF7;        Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString() + ".xls");        Response.ContentType = "application/ms-excel";        this.EnableViewState = false;        StringWriter tw = new StringWriter();        HtmlTextWriter hw = new HtmlTextWriter(tw);        GridView1.RenderControl(hw);        Response.Write(tw.ToString());        Response.End();    }    public override void VerifyRenderingInServerForm(Control control)    {    }    protected void printout_Click(object sender, EventArgs e)    {        Export("学生报名信息");    }}


[解决办法]
建议楼主把前台和后台的代码全部贴出来
[解决办法]
打开excel模板导出数据'

string style = @"<style> .text { mso-number-format:\@; } </script> "; 
Response.ClearContent();
Response.AddHeader("content-disposition", "attachment; filename=MyExcelFile.xls");
Response.ContentType = "application/excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
gv.RenderControl(htw);
Response.Write(style); 

Response.Write(sw.ToString());
Response.End();


public override void VerifyRenderingInServerForm(Control control)

{

}

热点排行