是否可以用代码生成水晶报表的小预览或缩略图?

发布于 2024-07-13 23:11:58 字数 163 浏览 3 评论 0原文

我正在使用 Crystal 在我的项目中显示报告,并且当用户从我的 UI 中选择要显示的报告时,我希望能够向用户显示报告的小预览或缩略图。 有什么方法可以从代码动态生成这些缩略图吗?

用户可以选择通过在报告文件夹中添加或删除报告来添加或删除报告,因此仅手动制作所有缩略图并不是真正的选择。

I'm using Crystal to display the reports in my project, and I'd like to be able to display a small preview or thumbnail image of the report to the user when he or she is picking a report to display from my UI. Is there any way to produce these thumbnails dynamically from code?

The user has the option to add or remove reports by adding or removing them from the reports folder, so just making all the thumbnail images by hand isn't really an option.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

故事↓在人 2024-07-20 23:11:58

我使用 DSOFile 对象获取报告内的缩略图,然后使用 AxHost 将返回的对象转换为我可以显示的图像。 这不是我想要的解决方案,但 DSOFile 是可自由分发的,所以我想这会起作用,直到我找到更好的东西。

  1. 下载并安装 Microsoft 的 DSOFile DLL。
  2. 的引用
  3. 添加对 **DSO OLE 文档属性阅读器 2.1代码

这是我的代码,精简为最低限度:

  namespace Ibs.Ui.OrderPrint
  {
    public partial class OrderPrintEdit
    {
       public OrderPrintEdit()
       {
        InitializeComponent();
       }

       #region -- reports_SelectedIndexChanged(sender, e) Event Handler --
       private void reports_SelectedIndexChanged(object sender, EventArgs e)
       {
           try
           {
               DSOFile.OleDocumentPropertiesClass oleDocumentPropertiesClass = new DSOFile.OleDocumentPropertiesClass();
               DirectoryInfo reportDirectory = new DirectoryInfo(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\Reports");
               oleDocumentPropertiesClass.Open(reportDirectory + "\\" + reports.Text,true,DSOFile.dsoFileOpenOptions.dsoOptionDontAutoCreate);
               Object thumbnail = oleDocumentPropertiesClass.SummaryProperties.Thumbnail;
               if (thumbnail != null)
               {
                   reportThumbnail.BackgroundImage = IPictureDispHost.GetPictureFromIPicture(thumbnail);
               }
               else
               {
                   reportThumbnail.BackgroundImage = null;
               }
               oleDocumentPropertiesClass.Close(false);
           }
           catch (Exception ex)
           {
           }
       }
       #endregion
   }

   internal sealed class IPictureDispHost : AxHost
   {
       private IPictureDispHost() : base("{63109182-966B-4e3c-A8B2-8BC4A88D221C}")
       {
       }
       /// <summary>
       /// Convert the dispatch interface into an image object.
       /// </summary>
       /// <param name="picture">The picture interface</param>
       /// <returns>An image instance.</returns>
       public new static Image GetPictureFromIPicture(object picture)
       {
           return AxHost.GetPictureFromIPicture(picture);
       }
   }

}

我在表单加载上用报告名称填充组合框。 在 SelectedIndexChanged 事件中,我从报告中获取 Thumbnail 对象并将其传递给转换方法。 这也适用于 Office 文档。

I used the DSOFile object to obtain the thumbnail inside the report then used AxHost to convert the returned object to an image I could display. This wasn't the solution I wanted but the DSOFile is freely distributable so I guess this will work until I find something better.

  1. Download and install the DSOFile DLL from Microsoft.
  2. Add a reference to **DSO OLE Document Properties Reader 2.1
  3. code

Here is my code, boiled down to the bare minimum:

  namespace Ibs.Ui.OrderPrint
  {
    public partial class OrderPrintEdit
    {
       public OrderPrintEdit()
       {
        InitializeComponent();
       }

       #region -- reports_SelectedIndexChanged(sender, e) Event Handler --
       private void reports_SelectedIndexChanged(object sender, EventArgs e)
       {
           try
           {
               DSOFile.OleDocumentPropertiesClass oleDocumentPropertiesClass = new DSOFile.OleDocumentPropertiesClass();
               DirectoryInfo reportDirectory = new DirectoryInfo(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\Reports");
               oleDocumentPropertiesClass.Open(reportDirectory + "\\" + reports.Text,true,DSOFile.dsoFileOpenOptions.dsoOptionDontAutoCreate);
               Object thumbnail = oleDocumentPropertiesClass.SummaryProperties.Thumbnail;
               if (thumbnail != null)
               {
                   reportThumbnail.BackgroundImage = IPictureDispHost.GetPictureFromIPicture(thumbnail);
               }
               else
               {
                   reportThumbnail.BackgroundImage = null;
               }
               oleDocumentPropertiesClass.Close(false);
           }
           catch (Exception ex)
           {
           }
       }
       #endregion
   }

   internal sealed class IPictureDispHost : AxHost
   {
       private IPictureDispHost() : base("{63109182-966B-4e3c-A8B2-8BC4A88D221C}")
       {
       }
       /// <summary>
       /// Convert the dispatch interface into an image object.
       /// </summary>
       /// <param name="picture">The picture interface</param>
       /// <returns>An image instance.</returns>
       public new static Image GetPictureFromIPicture(object picture)
       {
           return AxHost.GetPictureFromIPicture(picture);
       }
   }

}

I am filling a combobox with report names on the form load. In the SelectedIndexChanged event I get the Thumbnail object from the report and pass it to the conversion method. This should work for Office documents too.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文