Excel将数据导出到Excel C#时排除数字列中的前导零

时间:2017-04-24 06:33:15

标签: c# asp.net

protected void BTN_export_Click(object sender, EventArgs e)
{
    dt = (DataTable)(ViewState["allgrid"]);
    if (dt.Rows.Count > 0)
    {
        GridView GRD = new GridView();
        GRD.DataSource = dt;
        GRD.DataBind();
        Response.Clear();
        Response.Buffer = true;
        Response.Charset = "";
        this.EnableViewState = false;
        Response.ContentType = "application/vnd.ms-excel";
        StringWriter sw = new StringWriter();
        HtmlTextWriter htw = new HtmlTextWriter(sw);
        GRD.RenderControl(htw);
        Response.Write(sw.ToString());
        Response.End();
        Session["id"] = null;
    }
}

导出Excel时,它会排除一列中的前导零。以上是我的导出Excel代码

0 个答案:

没有答案