public void ExportReport(ReportDocument oReport, string cFileName, ExportTypes oExportTypes, int nFirstPage, int nLastPage) { ExportOptions oExportOptions = new ExportOptions(); PdfRtfWordFormatOptions oFormatOptions = ExportOptions.CreatePdfRtfWordFormatOptions(); DiskFileDestinationOptions oDestinationOptions = ExportOptions.CreateDiskFileDestinationOptions(); switch (oExportTypes) { case ExportTypes.PDF: case ExportTypes.MSWord: oExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat; PdfRtfWordFormatOptions oPDFFormatOptions = ExportOptions.CreatePdfRtfWordFormatOptions(); if (nFirstPage > 0 && nLastPage > 0) { oPDFFormatOptions.FirstPageNumber = nFirstPage; oPDFFormatOptions.LastPageNumber = nLastPage; oPDFFormatOptions.UsePageRange = true; } oExportOptions.ExportFormatOptions = oPDFFormatOptions; break; case ExportTypes.MSExcel: oExportOptions.ExportFormatType = ExportFormatType.Excel; ExcelFormatOptions oExcelFormatOptions = ExportOptions.CreateExcelFormatOptions(); if (nFirstPage > 0 && nLastPage > 0) { oExcelFormatOptions.FirstPageNumber = nFirstPage; oExcelFormatOptions.LastPageNumber = nLastPage; oExcelFormatOptions.UsePageRange = true; } oExcelFormatOptions.ExcelUseConstantColumnWidth = false; oExportOptions.ExportFormatOptions = oExcelFormatOptions; break; case ExportTypes.HTML: oExportOptions.ExportFormatType = ExportFormatType.HTML40; HTMLFormatOptions oHTMLFormatOptions = ExportOptions.CreateHTMLFormatOptions(); if (nFirstPage > 0 && nLastPage > 0) { oHTMLFormatOptions.FirstPageNumber = nFirstPage; oHTMLFormatOptions.LastPageNumber = nLastPage; oHTMLFormatOptions.UsePageRange = true; } // can set additional HTML export options here oExportOptions.ExportFormatOptions = oHTMLFormatOptions; break; } oDestinationOptions.DiskFileName = cFileName; oExportOptions.ExportDestinationOptions = oDestinationOptions; oExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; oReport.Export(oExportOptions); }