C# ExportaCrystalReporttoFilewithCustomOptions Snippets

C# ExportaCrystalReporttoFilewithCustomOptions Snippets

11. June 2009

Read this article in your language IT | EN | DE | ES

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>Export a Crystal Report to a PDF file with custom export format options</Title>
      <Author>Business Objects</Author>
      <Description>The following code example exports a Crystal Report to a PDF file with custom export format options.  For this code snippet to compile, add a reference to CrystalDecisions.CrystalReports.Engine.dll and CrystalDecisions.Shared.dll.</Description>
      <HelpUrl>http://www.businessobjects.com/products/dev_zone/net/default.asp</HelpUrl>
      <Shortcut>crExportRptWithOptions</Shortcut>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Declarations>
        <Literal>
          <ID>FileName</ID>
          <ToolTip>Replace this string with the name of the report file you want to export from.</ToolTip>
          <Default>"C:\My Crystal Reports\Report Name.rpt"</Default>
        </Literal>
        <Literal>
          <ID>DestinationFileName</ID>
          <ToolTip>Replace this string with the file name you want to export the report to.</ToolTip>
          <Default>"C:\My Crystal Reports\Report Name.pdf"</Default>
        </Literal>
        <Literal>
          <ID>usePageRange</ID>
          <ToolTip>Set this boolean to true if the FirstPageNumber and LastPageNumber should be used.</ToolTip>
          <Default>true</Default>
        </Literal>
        <Literal>
          <ID>startPage</ID>
          <ToolTip>Replace this number with the first page number to print; use 0 to specify whole report.</ToolTip>
          <Default>1</Default>
        </Literal>
        <Literal>
          <ID>endPage</ID>
          <ToolTip>Replace this number with the last page number to print; use 0 to specify whole report.</ToolTip>
          <Default>5</Default>
        </Literal>
        <Literal Editable="false">
          <ID>ReportDocumentClass</ID>
          <Function>SimpleTypeName(CrystalDecisions.CrystalReports.Engine.ReportDocument)</Function>
        </Literal>
        <Literal Editable="false">
          <ID>ExportOptionsClass</ID>
          <Function>SimpleTypeName(CrystalDecisions.Shared.ExportOptions)</Function>
        </Literal>
        <Literal Editable="false">
          <ID>ExportDestinationTypeClass</ID>
          <Function>SimpleTypeName(CrystalDecisions.Shared.ExportDestinationType)</Function>
        </Literal>
        <Literal Editable="false">
          <ID>ExportFormatTypeClass</ID>
          <Function>SimpleTypeName(CrystalDecisions.Shared.ExportFormatType)</Function>
        </Literal>
        <Literal Editable="false">
          <ID>PdfRtfWordFormatOptionsClass</ID>
          <Function>SimpleTypeName(CrystalDecisions.Shared.PdfRtfWordFormatOptions)</Function>
        </Literal>
        <Literal Editable="false">
          <ID>DiskFileDestinationOptionsClass</ID>
          <Function>SimpleTypeName(CrystalDecisions.Shared.DiskFileDestinationOptions)</Function>
        </Literal>
      </Declarations>
      <Code Language="csharp">
        <![CDATA[$ReportDocumentClass$ report = new $ReportDocumentClass$();
$ExportOptionsClass$ exportOptions = new $ExportOptionsClass$();
$PdfRtfWordFormatOptionsClass$ pdfExportFormatOptions = new $PdfRtfWordFormatOptionsClass$();
$DiskFileDestinationOptionsClass$ diskDestinationOptions = new $DiskFileDestinationOptionsClass$();

// Set the export format and format options

exportOptions.ExportFormatType = $ExportFormatTypeClass$.PortableDocFormat;
pdfExportFormatOptions.FirstPageNumber = $startPage$;
pdfExportFormatOptions.LastPageNumber = $endPage$;
pdfExportFormatOptions.UsePageRange = $usePageRange$;
exportOptions.ExportFormatOptions = pdfExportFormatOptions;

// Set the disk file options.

exportOptions.ExportDestinationType = $ExportDestinationTypeClass$.DiskFile;
diskDestinationOptions.DiskFileName = @$DestinationFileName$;
exportOptions.DestinationOptions = diskDestinationOptions;

report.Load(@$FileName$);
report.Export(exportOptions);
report.Close();$end$]]>
                </Code>
        </Snippet>
    </CodeSnippet>
</CodeSnippets>

FacebookDigg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

C# , ,

Comments

8/14/2009 9:06:28 PM #
I think you have to improve a bit the design and usability of your blog.
8/16/2009 7:25:51 PM #
I don't like your template but your posts are quite good so I will check back!
8/27/2009 6:04:03 AM #
Tried to autotranslate you site not understand the writing any hope deutsch version?
4/13/2010 8:25:55 AM #
Cheers to the writer for giving me various solid ideas  
5/7/2010 5:35:30 AM #
Awesome! Not clear for me, how often you�d updating your site?
5/9/2010 9:32:16 AM #
go figure Smile|Smile}

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading



Sayfa 0.015625 saniyede yuklendi.