日期:2014-05-17  浏览次数:20561 次

导出到Excel,不导出图片,那位大侠能解决。
代码如下:我的Repeater中是有图片的。请问,我导出的时候,怎么把图片给排除掉。

        public static void ToExcel(System.Web.UI.Control ctl, string FileName)
        {
            HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + FileName + ".xls");
            HttpContext.Current.Response.Charset = "UTF-8";
            HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default;
            HttpContext.Current.Response.ContentType = "application/ms-excel";//image/JPEG;text/HTML;image/GIF;vnd.ms-excel/msword 
            ctl.Page.EnableViewState = false;
            System.IO.StringWriter tw = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
            ctl.RenderControl(hw);
            HttpContext.Current.Response.Write(tw.ToString());
            HttpContext.Current.Response.End();
        }

Excel 图片 排除

------解决方案--------------------
Refer this:
remove img tag, then export to excel.

http://www.cnblogs.com/insus/p/3171983.html

------解决方案--------------------
    /// <summary>
        /// 导出Excel
        /// </summary>
        /// <param name="dtData"></param>