日期:2014-05-18 浏览次数:21072 次
//文本: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列开始的.
------解决方案--------------------
设置单元格的文本 Excel.Application.get_Range(excelApp.Cells[x1, y1], excelApp.Cells[x2, y2]).NumberFormatLocal="@"
------解决方案--------------------
mySheet.Cells(1,9).NumberFormatLocal = "@"
Excel.Range r = mySheet.get_Range(mySheet.Cells[1, 1], mySheet.Cells[1,3]);
r.NumberFormat = "@";
r.NumberForma = "0.00_ "
r.NumberForma = "¥#,##0.00;¥-#,##0.00"
r.NumberForma = _"_ ¥* #,##0.00_ ;_ ¥* -#,##0.00_ ;_ ¥* ""-""??_ ;_ @_ "
r.NumberForma = "yyyy-m-d"
r.NumberForma = "[$-F400]h:mm:ss AM/PM"
r.NumberForma = "000000"
myExcel.get_Range(myExcel.Cells[1, 1], myExcel.Cells[1, 1]).Font.Bold = true;
myExcel.get_Range(myExcel.Cells[1,1],myExcel.Cells[1,1]).Font.Size = 16;
------解决方案--------------------
dataTable 导出
------解决方案--------------------
//文本: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%