最近去折腾 水晶报表.
用水晶报表导出文件的时候, 有这样一个 文件类型选择:
对于终端用户来说, 导出这个 RPT 格式的文件 , 并没有多大的意义。
希望 格式的下拉列表里面, 不要出现 这个 类型的选择。
查看了一下 CrystalReportViewer 的属性, 里面有一个 int 类型 的 AllowedExportFormats 属性。
折腾了一下代码, 效果还行。
定义一个枚举.
/// /// 可导出的文件格式. /// public enum AllowedExportFormat { /// /// PDF. /// PDF = 1,
/// /// Excel(97-2003) /// Excel2003 = 2,
/// /// Word (97-2003) /// Word2003 = 4,
/// /// RTF /// RTF = 8,
/// /// Crystal Report /// CrystalReport = 16,
/// /// Excel(97-2003) (仅限数据) /// Excel2003DataOnly = 32,
/// /// Word (97-2003) - 可编辑 /// Word2003EditAble = 64,
/// /// XML /// XML = 128,
/// /// Excel (仅限数据) /// ExcelDataOnly = 512,
/// /// CSV /// CSV = 1024 }
设置控件的属性
CrystalReportViewer1.AllowedExportFormats = (int)(AllowedExportFormat.CSV | AllowedExportFormat.Excel2003 | AllowedExportFormat.Excel2003DataOnly | AllowedExportFormat.ExcelDataOnly | AllowedExportFormat.PDF | AllowedExportFormat.RTF | AllowedExportFormat.Word2003 | AllowedExportFormat.Word2003EditAble | AllowedExportFormat.XML);
最后运行的结果:
转自:http://hi.baidu.com/wangzhiqing999/blog/item/71eaf53cd3a5d80296ddd867.html