在Stimulsoft Reports.Net中使用StiHtmlImageHost类

作者:mayz    来源:慧都控件网    浏览:Loading...      日期:2012-10-26

问题描述:

在Stimulsoft Reports.Net中使用StiHtmlImageHost类

问题解答:

你可以创建自己的StiHtmlImageHost类并覆盖默认的行为,然后你可以通过以下代码调用这个类:
[C#]

StiHtmlExportService service = new StiHtmlExportService();
service.HtmlImageHost = new MyHtmlImageHost();
service.ExportHtml(report, Stream);

public class StiWebImageHost : StiHtmlImageHost
{
  public override string GetImageString(Bitmap bmp)
  {
    Guid imageGuid = Guid.NewGuid();

    MemoryStream imageStream = new MemoryStream();
    bmp.Save(imageStream, webViewer.ImageFormat);

    if (webViewer.CacheMode == StiCacheMode.Page)
    {
      webViewer.Page.Cache.Add(imageGuid.ToString(), imageStream.ToArray(), null, Cache.NoAbsoluteExpiration,
      webViewer.ServerTimeOut, System.Web.Caching.CacheItemPriority.Low, null);
    }
    else
    {
      webViewer.Page.Session.Add(imageGuid.ToString(), imageStream.ToArray());
    }

    string url = webViewer.Page.Request.Url.AbsolutePath;
    string query = webViewer.Page.Request.Url.Query;

    if (query != null && query.Length > 0)
    {
      return string.Format("{0}{1}&stimulreport_image={2}", url, query, imageGuid);
    }
    else
    {
      return string.Format("{0}?stimulreport_image={1}", url, imageGuid);
    }
  }

  private StiWebViewer webViewer = null;

  public StiWebImageHost(StiWebViewer webViewer) : base (null)
  {
    this.webViewer = webViewer;
  }
}

 

Tag标签:.NET报表 Stimulsoft Reports.Net 

本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:Stimulsoft中文网 [http://www.Stimulsoft.cn/]
本文地址: http://www.Stimulsoft.cn/Resources/FAQ/127.html

上一篇: 将StimulsoftReports.Net报表中的DateTime导入Excel表格中

下一篇: 如何隐藏StimulsoftReports.Net报表设计器面板