如何限制水晶报表中的导出格式

时间:2011-03-01 08:28:06

标签: crystal-reports

对于visual studio .net 2005的Crystal报表,您可以导出报表 各种文件格式,如pdf,excel,word,rpt等。如果我只是想 限制用户只看到excel和word格式并设置默认文件 格式要优秀,有没有办法做到这一点?有时选择太多了 不好,是吗?

4 个答案:

答案 0 :(得分:6)

使用CRVS2010,您可以删除不需要的导出选项。

CRVS2010的一项新功能是能够从查看器导出按钮修改可用的导出格式。以下C#示例代码演示了如何将CrystalReportViewer设置为仅导出为PDF和Excel文件格式:

int exportFormatFlags = (int)(CrystalDecisions.Shared.ViewerExportFormats.PdfFormat | CrystalDecisions.Shared.ViewerExportFormats.ExcelFormat);
CrystalReportViewer1.AllowedExportFormats = exportFormatFlags;

更多详情请参阅以下链接..

http://scn.sap.com/community/crystal-reports-for-visual-studio/blog/2011/01/26/export-file-formats-for-sap-crystal-reports-for-vs-2010

答案 1 :(得分:4)

试试这个:

    Dim formats As Integer
    formats = (CrystalDecisions.Shared.ViewerExportFormats.PdfFormat Or CrystalDecisions.Shared.ViewerExportFormats.XLSXFormat)

    CrystalReportViewer1.AllowedExportFormats = formats

答案 2 :(得分:2)

要禁用Crystal Report Rpt格式,请尝试以下操作:

select
      gtl3.*
   from
      SELECT
            gtl2.username,
            min( gtl2.id ) as FirstGameTimeIDWithCommonHighPoint
         from
            ( select
                    gtl.username,
                    MAX( gtl.point ) as highestPointPerUser
                 from
                    game_toplist gtl
                 group by
                    gtl.username
                 order by 
                  MAX( gtl.point ) DESC
                 limit 100 ) as Top100
              JOIN game_toplist gtl2
                 ON Top100.username = gtl2.username
                 AND Top100.highestPointPerUser = gtl2.point ) as SinglePerUser
         join game_toplist gtl3
            on SinglePerUser.username = gtl3.username
           AND SinglePerUser.FirstGameTimeIDWithCommonHighPoint = gtl3.ID
   order by
      gtl3.point DESC

答案 3 :(得分:1)

您没有提到您使用的是C#/ VB.NET还是Web / WinForms。

<强> C#

我不认为这是可能的。您必须实现自己的导出按钮。

MSDN article

的内容

<强> C#

// Declare variables and get the export options.
ExportOptions exportOpts = new ExportOptions();
ExcelFormatOptions excelFormatOpts = new ExcelFormatOptions ();
DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();
exportOpts = Report.ExportOptions;

// Set the excel format options.
excelFormatOpts.ExcelUseConstantColumnWidth = true;
exportOpts.ExportFormatType = ExportFormatType.Excel;
exportOpts.FormatOptions = excelFormatOpts;

// Set the disk file options and export.
exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;
diskOpts.DiskFileName = fileName;
exportOpts.DestinationOptions = diskOpts;

Report.Export ();

<强> VB.NET

' Declare variables and get the export options.
Dim exportOpts As New ExportOptions()
Dim diskOpts As New DiskFileDestinationOptions()
Dim excelFormatOpts As New ExcelFormatOptions()
exportOpts = Report.ExportOptions

' Set the excel format options.
excelFormatOpts.ExcelTabHasColumnHeadings = true

exportOpts.ExportFormatType = ExportFormatType.Excel
exportOpts.FormatOptions = excelFormatOpts

' Set the export format.
exportOpts.ExportFormatType = ExportFormatType.Excel

exportOpts.ExportDestinationType = ExportDestinationType.DiskFile

' Set the disk file options.
diskOpts.DiskFileName = fileName
exportOpts.DestinationOptions = diskOpts

Report.Export()

<强> VB.NET

您曾经能够从客户端安装中删除某些导出DLL。即从Excel DLL中删除所有内容,然后它只显示导出选项为Excel