菜鸟向高手的提问
导出EXCEL时,身份证号以“科学技术法”显示于EXCEL中,当双击后其值可以全部看到,但是后几位都变成了零,如何导出后身份证号不按科学技术法显示?
我用C#编写的代码,大致如下:
private void Export(string FileType, string FileName)//导出Excel
{
GridView GridView2 = new GridView();
GridView2.DataSource = (DataView)Session["dvlist7"];
GridView2.DataBind();
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.GetEncoding("GB2312")).ToString());
Response.ContentType = FileType;
this.EnableViewState = false;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
GridView2.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();
}
public override void VerifyRenderingInServerForm(Control control)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
Export("application/ms-excel", "基本信息查询.xls");
}