I am converting datatable data to html content from code behind then exporting html table to excel.
(我将数据表数据从后面的代码转换为html内容,然后将html表导出到excel。)
There is logo at header which is displaying at local.(标头上有徽标,该徽标显示在本地。)
but not from other computer.(但不是来自其他计算机。)
I tried embedded image too ( base64 ) but facing same issue.(我也尝试过嵌入式图像(base64),但是面临相同的问题。)
string baseUrl = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath+ "ExcelReports\ReportLogo.png";
string data_1 = string.Empty;
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
// HttpContext.Current.Response.Write(@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">");
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + reportname + ".xls");
HttpContext.Current.Response.Charset = "utf-8";
data_1 = "<font style='font-size:10.0pt; font-family:Calibri;'><BR><BR><BR><Table><tr><td><img src="+baseUrl+" alt='Red dot' /></td></tr></Table><BR><BR><BR><BR><Table><tr><td>Created By : " + createdby + "</td><td></td><td></td><td></td><td>Created DateTime : " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "</td></Table><BR><Table border='1' bgColor='#ffffff' " + "borderColor='#000000' cellSpacing='0' cellPadding='0' " + "style='font-size:10.0pt; font-family:Calibri; background:white;'> <TR>";
int columnscount = table.Columns.Count;
string data_2 = string.Empty;
for (int j = 0; j < columnscount; j++)
{
data_2 += "<Td>";
data_2 += "<B>";
data_2 += table.Columns[j].ToString();
data_2 += "<B>";
data_2 += "</Td>";
}
ask by Yogesh Jadhav translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…