For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic Crystal Reports > January 2006 > Newbie's question - vb.net and Crystal 10









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Newbie's question - vb.net and Crystal 10
Kay

2006-01-19, 9:58 pm

Hi all,

I'm writing a vb.net app that allow user to view several reports on one
screen. Now I'm working on the first one, which should be quite simple.

The report require a date value, and after clicking on the button, the user
will get a pdf version of the report, and I don't really want to show the
crystal viewer on screen.

So wondering can someone give me some help, I tried to search the internet
but all example I got is using a crystal viewer. I'm also wondering, how do
I pass more than 1 paramater to the report? i.e. A Date range like from
Date1 to Date2 ?

Thanks!!

Kay


Kay

2006-01-20, 3:59 am

After I've done a bit more research, found a post said that I must use the
crystal viewer before I can export a report to PDF...is it correct?

? Kay ?


"Kay" <kk@micxsoft.com> wrote in message
news:%23iYBGlWHGHA.2836@TK2MSFTNGP14.phx.gbl...
> Hi all,
>
> I'm writing a vb.net app that allow user to view several reports on one
> screen. Now I'm working on the first one, which should be quite simple.
>
> The report require a date value, and after clicking on the button, the
> user will get a pdf version of the report, and I don't really want to show
> the crystal viewer on screen.
>
> So wondering can someone give me some help, I tried to search the internet
> but all example I got is using a crystal viewer. I'm also wondering, how
> do I pass more than 1 paramater to the report? i.e. A Date range like
> from Date1 to Date2 ?
>
> Thanks!!
>
> Kay
>



n33470

2006-01-20, 7:11 pm

Kay,

If all you want to do is generate a PDF file from a report, then no you
do not need to use the crystal viewer to do that. You *can* export
to PDF from the viewer, but you can also programmatically export to
PDF.

I'm almost certain there is a full-blown sample of this on the Crystal
web site in the Developer Zone. In the meantime, here's a snipet of
code that might point you in the right direction:

public void ExportToPDF( string fileName )
{

ReportDocument report = new ReportDocument();
report.Load ( this.TemplateFile );

// push the dataset into the report
report.SetDataSource( this.ReportDataset );

PdfRtfWordFormatOptions pdfRtfWordOpts = new PdfRtfWordFormatOptions
();

// Set the export format.
pdfRtfWordOpts.FirstPageNumber = 1;
pdfRtfWordOpts.LastPageNumber = 1;
pdfRtfWordOpts.UsePageRange = false;
report.ExportOptions.ExportFormatType =
ExportFormatType.PortableDocFormat;
report.ExportOptions.FormatOptions = pdfRtfWordOpts;

// Set the disk file options and export.
DiskFileDestinationOptions diskOpts = new
DiskFileDestinationOptions();
report.ExportOptions.ExportDestinationType =
ExportDestinationType.DiskFile;
diskOpts.DiskFileName = fileName;
report.ExportOptions.DestinationOptions = diskOpts;

report.Export();
}

--steve

Kay wrote:[color=darkred]
> After I've done a bit more research, found a post said that I must use the
> crystal viewer before I can export a report to PDF...is it correct?
>
> ? Kay ?
>
>
> "Kay" <kk@micxsoft.com> wrote in message
> news:%23iYBGlWHGHA.2836@TK2MSFTNGP14.phx.gbl...

Kay

2006-01-22, 10:00 pm

Hi n33470,

I got more samples from Crystal's web site, thanks for your help :D

Kay


"n33470" <n33470@hotmail.com> wrote in message
news:1137777447.184954.52060@g43g2000cwa.googlegroups.com...
> Kay,
>
> If all you want to do is generate a PDF file from a report, then no you
> do not need to use the crystal viewer to do that. You *can* export
> to PDF from the viewer, but you can also programmatically export to
> PDF.
>
> I'm almost certain there is a full-blown sample of this on the Crystal
> web site in the Developer Zone. In the meantime, here's a snipet of
> code that might point you in the right direction:
>
> public void ExportToPDF( string fileName )
> {
>
> ReportDocument report = new ReportDocument();
> report.Load ( this.TemplateFile );
>
> // push the dataset into the report
> report.SetDataSource( this.ReportDataset );
>
> PdfRtfWordFormatOptions pdfRtfWordOpts = new PdfRtfWordFormatOptions
> ();
>
> // Set the export format.
> pdfRtfWordOpts.FirstPageNumber = 1;
> pdfRtfWordOpts.LastPageNumber = 1;
> pdfRtfWordOpts.UsePageRange = false;
> report.ExportOptions.ExportFormatType =
> ExportFormatType.PortableDocFormat;
> report.ExportOptions.FormatOptions = pdfRtfWordOpts;
>
> // Set the disk file options and export.
> DiskFileDestinationOptions diskOpts = new
> DiskFileDestinationOptions();
> report.ExportOptions.ExportDestinationType =
> ExportDestinationType.DiskFile;
> diskOpts.DiskFileName = fileName;
> report.ExportOptions.DestinationOptions = diskOpts;
>
> report.Export();
> }
>
> --steve
>
> Kay wrote:
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com