【问题标题】:Report Builder PrintToFile Types报表生成器 PrintToFile 类型
【发布时间】:2016-07-18 01:53:43
【问题描述】:

我有一个关于报表生成器的问题,因为我们将它用于我们的报告目的。

在打印预览屏幕的左上角有一个打印机图标。单击它会打开“打印”对话框,其中有“打印到文件”选项。在该选项中,您可以选择类型(PDF 文件、XLS 报告文件等)。我的问题是:“有没有可能知道用户选择了哪个类型的运行类型?”。换句话说,我需要知道他是否选择了“PDF 文件”或“XLS 报告文件”或其他什么?

我试图在 ppReportBeforePrint 事件中捕获 ppReport.DeviceType 属性,但它显示所有类型的导出的“打印机”。

我附上了打印对话框的屏幕截图以便更好地理解。

我们在 Windows 8.1 下使用 Delphi XE3 + Report Builder 15.03。

【问题讨论】:

    标签: delphi delphi-xe3 reportbuilder


    【解决方案1】:

    要分隔导出类型,您可以使用以下代码:

    procedure TForm1.ppReport1BeforePrint(Sender: TObject);
    begin
      if ppReport1.DeviceType = 'Screen' then
        // Preview Report on the Screen
      else if ppReport1.DeviceType = 'Printer' then
      begin
        if (ppReport1.FileDevice is TppXLSReportDevice) then
          // Export to Excel
        else if (ppReport1.FileDevice is TppPDFDevice) then
          // Export to PDF
      end;
    end;
    

    要在预览屏幕上启用打印机按钮,请使用:

    ppReport1.AllowPrintToFile := True;
    

    【讨论】:

      猜你喜欢
      • 2011-04-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多