在GridView行绑定时添加如下代码即可
//消除Excel导出时长数字自动变成科学计数法
for
(
int
i
=
0
; i
<
e.Row.Cells.Count; i
++
)
{
e.Row.Cells[i].Attributes.Add( " style " , " vnd.ms-excel.numberformat:@ " );
}
{
e.Row.Cells[i].Attributes.Add( " style " , " vnd.ms-excel.numberformat:@ " );
}
//=============================
以上方法会把导出的Excel列中每一列都取消格式,但是这样Excel无法进行某些操作,如无法改变日期格式或者统计列
需要操作的列则不能使用此方法,只需在长数字那一列用此方法,如是第一列,则代码为:
e.Row.Cells[0].Attributes.Add("style", "vnd.ms-excel.numberformat:@");