用模板Excel导出,不要直接导出,然后设置模板里面的身份证号码那列为数字就可以了

解决方案 »

  1.   

    因为你的数据源是DataTable,所以你可以在DataTable中添加一列年龄列,关于如何在DataTable中添加列,参考
    http://msdn.microsoft.com/ZH-CN/library/hfx3s9wd(v=vs.110).aspx
    创建表达式列
    关于输出数据类型的问题,看看下面的链接,或者你给身份证那列前面加上单引号,这样Excel会识别为文本
    Export GridView to Excel in ASP.Net with Formatting using C# and VB.Net
      

  2.   

    处理输出文本关键是在RenderControl后面加一行输出的格式        gvw.RenderControl(hw);
            //string style = @"<style> .textmode {mso-number-format:General} </style>";
            string style = @"style> .textmode { mso-number-format:\@; } </style> </style>";
            Response.Output.Write(tw.ToString());
      

  3.   

    上面代码错了        gvw.RenderControl(hw);
            //string style = @"<style> .textmode {mso-number-format:General} </style>";
            string style = @"<style> .textmode { mso-number-format:\@; } </style>";
            Response.Output.Write(tw.ToString());