locked
Default Export Format of Report Viewer RRS feed

  • Question

  • User733208215 posted

    Hi,

    I am asked to set the default export format (pdf) of Report Viewer. But, I only find "ShowExportControls", Report Viewer does not have Default Export Format.

    Is there any method (coding) set the default export format to pdf?

    Monday, October 31, 2011 2:34 AM

All replies

  • User1918766559 posted

    The Crystal Report Engine allows you to deliver reports in many different ways. Using the export option, you can send the report to a disk file, to an Exchange folder, or to MS Mail (MAPI). The report can be exported to Excel, Crystal Reports, Microsoft Word, HTML, Portable Document Format (PDF), or Rich Text (RTF) format.

    There are three ways you can set up users' export options:

    • Leave the default Export Expert button on the CrystalReportViewer toolbar.
    • Create your own button that calls the Export Expert dialog box. This method allows you to hide the standard toolbar when you require none of its other functions or when you want to customize the interface. This is available only through the Windows Forms Viewer.
    • Write code to specify a particular export type and destination.

    // Declare variables and get the export options.

    ExportOptions exportOpts = new ExportOptions();

    PdfFormatOptions pdfFormatOpts = new PDFFormatOptions ();

    DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();

    exportOpts = Report.ExportOptions;

    // Set the excel format options.

    pdfFormatOpts.ExcelUseConstantColumnWidth = true;

    exportOpts.ExportFormatType = ExportFormatType.Pdf;

    exportOpts.FormatOptions = pdfFormatOpts;

    // Set the disk file options and export.

    exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;

    diskOpts.DiskFileName = fileName;

    exportOpts.DestinationOptions = diskOpts;

    Report.Export (); 

    Details: http://msdn.microsoft.com/en-us/library/aa288404(v=vs.71).aspx 

    Thanks,

    Anindita

    http://anindita9.wordpress.com

    Monday, October 31, 2011 2:45 AM
  • User1426937062 posted

    Hi,

    You can do this by changing the order of xml tag in config file of reportserver (C:\Program Files\Microsoft SQL Server\MSSQL.2\Reporting Services\Report Server\ rsreportserver.config). if you need to set the PDF export should be the default then find the below line in config file and order it first under <Render> tag.

    <Extension Name="PDF" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.PDFRenderer,Microsoft.ReportingServices.ImageRendering"/>

     

    Monday, October 31, 2011 3:05 AM
  • User733208215 posted

    • Leave the default Export Expert button on the CrystalReportViewer toolbar.
    • Create your own button that calls the Export Expert dialog box. This method allows you to hide the standard toolbar when you require none of its other functions or when you want to customize the interface. This is available only through the Windows Forms Viewer.
    • Write code to specify a particular export type and destination.

    I use ASP.net and c#.net in my project. As you mentioned (second point), do you mean I cannot set the default export format as pdf using code?

    Monday, October 31, 2011 3:29 AM
  • User733208215 posted

    Hi,

    You can do this by changing the order of xml tag in config file of reportserver (C:\Program Files\Microsoft SQL Server\MSSQL.2\Reporting Services\Report Server\ rsreportserver.config). if you need to set the PDF export should be the default then find the below line in config file and order it first under <Render> tag.

    <Extension Name="PDF" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.PDFRenderer,Microsoft.ReportingServices.ImageRendering"/>

     

    Since Report Viewer is used in many projects, I do not prefer to change the config file.

    Apart from updating config file, is there any method to do it, e.g. in coding when loading date to the page?

    Monday, October 31, 2011 3:34 AM