
 Code
Code
protected void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
    {
        //if (e.Item.ItemType == ListItemType.Item)
        //{
        //    e.Item.Cells[3].Attributes.Add("class", "text");
        //}
        e.Item.Cells[3].Attributes.Add("class", "text");
        //出仓报关单号
        e.Item.Cells[24].Attributes.Add("class", "text");
    }
 Code
Code
 protected void Button1_Click(object sender, EventArgs e)
    {
        //导出
        Response.Clear();
        Response.AddHeader("content-disposition", "attachment; filename=FileName1.xls");
        Response.Charset = "";
        Response.ContentType = "application/vnd.xls";
        System.IO.StringWriter stringWrite = new System.IO.StringWriter();
        System.Web.UI.HtmlTextWriter htmlWrite =
        new HtmlTextWriter(stringWrite);
        dtgStoreBillOutList.RenderControl(htmlWrite);
        string style = @"<style> .text { mso-number-format:\@; } </style> ";
        Response.Write(style);
        Response.Write(stringWrite.ToString());
        Response.End();
    }其中:
dtgStoreBillOutList 是datagrid名称