110,533
社区成员
发帖
与我相关
我的任务
分享
//文本:vnd.ms-excel.numberformat:@
//日期:vnd.ms-excel.numberformat:yyyy/mm/dd
//数字:vnd.ms-excel.numberformat::#,##0.00
//货币:vnd.ms-excel.numberformat¥#,##0.00
//百分比:vnd.ms-excel.numberformat:#0.00%
//在excel中数字位数大于11位,都会默认以科学技术法出现,所以有E+.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
for(int i=0;i<e.Row.Cells.Count;i++)
{
if(e.Row.RowType==DataControlRowType.DataRow)
{
//表示对每一行以字符串的形式输出
e.Row.Cells[i].Attributes.Add("style","vnd.ms-excel.numberformat:@");
}
}
}
//如果你想对导出的execl的某一行进行以字符串输出,而不想用科学计数法出现,则需要上面方法,最好对某一列以字符串输出,excel也是从0列开始的.