对于visual studio .net 2005的Crystal报表,您可以将报表导出为各种文件格式,如pdf,excel,word,rpt等.如果我只想限制用户只看excel和word格式并设置默认文件格式要超越,有办法吗?有时太多选择不好,是吗?
使用CRVS2010,您可以删除不需要的导出选项.
CRVS2010的一项新功能是能够从查看器导出按钮修改可用的导出格式.以下C#示例代码演示了如何将CrystalReportViewer设置为仅导出为PDF和Excel文件格式:
int exportFormatFlags = (int)(CrystalDecisions.Shared.ViewerExportFormats.PdfFormat | CrystalDecisions.Shared.ViewerExportFormats.ExcelFormat);
CrystalReportViewer1.AllowedExportFormats = exportFormatFlags;
Run Code Online (Sandbox Code Playgroud)
更多详情请参考以下链接..
您没有提及您使用的是 C# / VB.NET 还是 Web/WinForms。
C#
我认为这是不可能的。您必须实现自己的导出按钮。
类似于这篇MSDN 文章的内容
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 ();
Run Code Online (Sandbox Code Playgroud)
网络
' 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()
Run Code Online (Sandbox Code Playgroud)
网络
您过去可以从客户端安装中删除某些导出 DLL。即删除除 Excel DLL 之外的所有内容,然后它只会将导出选项显示为 Excel
| 归档时间: |
|
| 查看次数: |
14238 次 |
| 最近记录: |