HttpContext.Current.Response.ContentType = "application/application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; HttpContext.Current.Response.Write(@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">"); HttpContext.Current.Response.AppendHeader("content-disposition", "attachment;filename=Reports.xlsx"); HttpContext.Current.Response.Charset = "utf-8"; HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1250"); HttpContext.Current.Response.Write("<font style='font-size:10.0pt; font-family:Calibri;'>"); HttpContext.Current.Response.Write("<BR><BR><BR>"); HttpContext.Current.Response.Write("<Table border='1' bgColor='#ffffff' borderColor='#000000' cellSpacing='0' cellPadding='0' style='font-size:10.0pt; font-family:Calibri;'> <TR>");
HttpContext.Current.Response.Write("<Table border='1' bgColor='#ffffff' borderColor='#000000' cellSpacing='0' cellPadding='0' style='font-size:10.0pt; font-family:Calibri;'> <TR>"); int columnscount = dtHeader.Columns.Count; for (int j = 0; j < columnscount; j++) { HttpContext.Current.Response.Write("<Td>"); HttpContext.Current.Response.Write(""); HttpContext.Current.Response.Write(dtHeader.Columns[j].ColumnName.ToString()); HttpContext.Current.Response.Write(""); HttpContext.Current.Response.Write("</Td>"); } HttpContext.Current.Response.Write("</TR>"); foreach (DataRow row in dtHeader.Rows) { HttpContext.Current.Response.Write("<TR>"); for (int i = 0; i < dtHeader.Columns.Count; i++) { HttpContext.Current.Response.Write("<Td>"); HttpContext.Current.Response.Write(row[i].ToString()); HttpContext.Current.Response.Write("</Td>"); } HttpContext.Current.Response.Write("</TR>"); } HttpContext.Current.Response.Write("</Table>");
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)