网上拷贝的一段:
public void ExportCrystalReport(DataSet myDS,string targetFileName,string reportPath,string docFormat,string passWrd)
{
ReportDocument oRD = new ReportDocument();
ExportOptions oExO ;
DiskFileDestinationOptions oExDo=new DiskFileDestinationOptions();
oRD.Load(reportPath);
oRD.SetDataSource(myDS);
oRD.Refresh();
this.SetConnectionInfo(oRD,passWrd);
oExDo.DiskFileName = targetFileName;
oExO = oRD.ExportOptions;
oExO.ExportDestinationType = ExportDestinationType.DiskFile;
switch (docFormat)
{
case "pdf ":
oExO.ExportFormatType = ExportFormatType.PortableDocFormat;
break;
case "doc ":
oExO.ExportFormatType = ExportFormatType.WordForWindows;
break;
case "xls ":
oExO.ExportFormatType = ExportFormatType.Excel;
break;
case "htm ":
oExO.ExportFormatType = ExportFormatType.HTML40;
break;
case "html ":
oExO.ExportFormatType = ExportFormatType.HTML40;
break;
default:oExO.ExportFormatType = ExportFormatType.Excel;break;
}
oExO.DestinationOptions = oExDo;
oRD.Export();
oRD.Close();
}