//1) 文本:vnd.ms-excel.numberformat:@//2) 日期:vnd.ms-excel.numberformat:yyyy/mm/dd//3) 数字:vnd.ms-excel.numberformat:#,##0.00//4) 货币:vnd.ms-excel.numberformat:¥#,##0.00//5) 百分比:vnd.ms-excel.numberformat: #0.00%
HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Charset = ""; HttpContext.Current.Response.ContentType = "application/vnd.ms-xls"; HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode(excelname + ".xls")); StringBuilder table = new StringBuilder(); DataTable dt = ds.Tables[0]; table.Append("
"); table.Append(dt.Columns[i].Caption.ToString()); //标格的标题 table.Append(" | "); } table.Append("
"); table.Append(dt.Rows[i][j].ToString()); table.Append(" | "); } table.Append("