Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
359 views
in Technique[技术] by (71.8m points)

javascript - 嵌入式图像使用显示在localhost而非远程站点上的asp.net导出到excel图像(Embedded image Export to excel image using asp.net showing on localhost not on remote site)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...