通常在Gridview中将数据导出为excel时,身份证号码常常被以科学计数法显式,影响导出的正确性,经过在网上查找资料,发现用下面的方法可以解决这种问题
在gridview的rowdatabound事件中写下面的代码
if (e.row.rowtype=datacontrolrowtype.datarow) then
e.row.cell(i).attributes.add("style","vnd.ms-excel.numberformat:@;")
end if
其中i为身份证号码的那一列,数的时候从0开始,其实也就是加了个格式,更多的解答请用vnd.ms-excel.numberformat做关键词搜索