对于visual studio .net 2005的Crystal报表,您可以导出报表 各种文件格式,如pdf,excel,word,rpt等。如果我只是想 限制用户只看到excel和word格式并设置默认文件 格式要优秀,有没有办法做到这一点?有时选择太多了 不好,是吗?
答案 0 :(得分:6)
使用CRVS2010,您可以删除不需要的导出选项。
CRVS2010的一项新功能是能够从查看器导出按钮修改可用的导出格式。以下C#示例代码演示了如何将CrystalReportViewer设置为仅导出为PDF和Excel文件格式:
int exportFormatFlags = (int)(CrystalDecisions.Shared.ViewerExportFormats.PdfFormat | CrystalDecisions.Shared.ViewerExportFormats.ExcelFormat);
CrystalReportViewer1.AllowedExportFormats = exportFormatFlags;
更多详情请参阅以下链接..
答案 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#强>
我不认为这是可能的。您必须实现自己的导出按钮。
的内容<强> 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