水晶報表在C#使用中經常需要事先導出 功能,但是crystalReportVIEwer在界面上不太美觀,所以貼出來共享。
CrystalDecisions.Shared.DiskFileDestinationOptions DiskOpts = new CrystalDecisions.Shared.DiskFileDestinationOptions();
this.reportDocument1.ExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;
SaveFileDialog SaveFileDialog1 = new SaveFileDialog();
SaveFileDialog1.Filter = "Microsoft Office Excel 文件 (*.xls)|*.xls|Microsoft Office Word 文件 (*.doc)|*.doc|Microsoft Office RichText 文件 (*.rtf)|*.rtf|Adobe PDF 文件 (*.pdf)|*.pdf";
SaveFileDialog1.FilterIndex = 1; //默認Microsoft Office Excel
SaveFileDialog1.RestoreDirectory = true;
SaveFileDialog1.FileName = "報表_" + DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day; //默認圖片保存名稱 Pic01
if (SaveFileDialog1.ShowDialog() == DialogResult.OK)
{
switch (SaveFileDialog1.FilterIndex)
{
case 1:
this.reportDocument1.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.Excel;
break;
&