| | |
| | | { |
| | | StringBuilder stringBuilder = new StringBuilder(); |
| | | //stringBuilder.Append("<meta http-equiv=\"content-type\" content=\"application/ms-excel; charset=UTF-8\"/>");//旧的-导出xls |
| | | stringBuilder.Append("<meta http-equiv=\"content-type\" content=\"vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8\"/>");//导出格式xlsx |
| | | //stringBuilder.Append("<meta http-equiv=\"content-type\" content=\"vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=UTF-8\"/>");//导出格式xlsx |
| | | stringBuilder.Append("<meta http-equiv=\"content-type\" content=\"text/csv\"/>");//导出格式xlsx |
| | | stringBuilder.AppendLine("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">"); |
| | | stringBuilder.AppendLine("<tr>"); |
| | | foreach (KeyValuePair<string, string> keyValuePair in dictionary) |
| | |
| | | } |
| | | stringBuilder.AppendLine("</table>"); |
| | | Response.ClearContent(); |
| | | Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName + ".xlsx"); |
| | | Response.ContentType = "application/excel"; |
| | | Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName + ".csv"); |
| | | Response.ContentType = "text/csv"; |
| | | //Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName + ".xlsx"); |
| | | //Response.ContentType = "application/execl"; |
| | | Response.ContentEncoding = Encoding.UTF8; |
| | | Response.Write(stringBuilder.ToString()); |
| | | Response.End(); |