// To create the DataSet by adding Add->new Item..
private void btnReport_Click(object sender, EventArgs e)
{
ReportDocument cryRpt;
ExportOptions CrExportOptions;
DiskFileDestinationOptions CrDiskFileDestinationOptions;
PdfRtfWordFormatOptions CrFormatTypeOptions;
cryRpt = new ReportDocument();
cryRpt.Load("C:\\LawrenceSoft\\Sample.rpt");
DataSet DataNew = new DataSet();
DataNew.ReadXml("F:\\LawrenceSoft\\VatDetails.xml");
DataTable dtReportSource = (DataTable)DataNew.Tables[0];
cryRpt.SetDataSource(dtReportSource);
CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
CrFormatTypeOptions = new PdfRtfWordFormatOptions();
SaveFileDialog sfdSavePDF = new SaveFileDialog();
sfdSavePDF.OverwritePrompt = true;
sfdSavePDF.SupportMultiDottedExtensions = true;
sfdSavePDF.Filter = "PDF files (*.pdf)|*.pdf";
sfdSavePDF.ShowDialog(this);
CrDiskFileDestinationOptions.DiskFileName = sfdSavePDF.FileName;//@"c:\\test.pdf";
if (string.IsNullOrEmpty(CrDiskFileDestinationOptions.DiskFileName) == false)
{
CrExportOptions = cryRpt.ExportOptions;
{
CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
CrExportOptions.FormatOptions = CrFormatTypeOptions;
}
cryRpt.Export();
}
}
//To use the Report Viewer for showing the Crystal Report..
DataSet DataNew = new DataSet();
DataNew.ReadXml("F:\\LawrenceSoft\\VatDetails.xml");
DataTable dtReportSource = (DataTable)DataNew.Tables[0];
ReportDocument rdSample = new ReportDocument();
rdSample.Load("C:\\LawrenceSoft\\Sample.rpt");
rdSample.SetDataSource(dtReportSource);
crystalReportViewer1.Visible = true;
crystalReportViewer1.ReportSource = rdSample;
crystalReportViewer1.Refresh();
private void btnReport_Click(object sender, EventArgs e)
{
ReportDocument cryRpt;
ExportOptions CrExportOptions;
DiskFileDestinationOptions CrDiskFileDestinationOptions;
PdfRtfWordFormatOptions CrFormatTypeOptions;
cryRpt = new ReportDocument();
cryRpt.Load("C:\\LawrenceSoft\\Sample.rpt");
DataSet DataNew = new DataSet();
DataNew.ReadXml("F:\\LawrenceSoft\\VatDetails.xml");
DataTable dtReportSource = (DataTable)DataNew.Tables[0];
cryRpt.SetDataSource(dtReportSource);
CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
CrFormatTypeOptions = new PdfRtfWordFormatOptions();
SaveFileDialog sfdSavePDF = new SaveFileDialog();
sfdSavePDF.OverwritePrompt = true;
sfdSavePDF.SupportMultiDottedExtensions = true;
sfdSavePDF.Filter = "PDF files (*.pdf)|*.pdf";
sfdSavePDF.ShowDialog(this);
CrDiskFileDestinationOptions.DiskFileName = sfdSavePDF.FileName;//@"c:\\test.pdf";
if (string.IsNullOrEmpty(CrDiskFileDestinationOptions.DiskFileName) == false)
{
CrExportOptions = cryRpt.ExportOptions;
{
CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
CrExportOptions.FormatOptions = CrFormatTypeOptions;
}
cryRpt.Export();
}
}
//To use the Report Viewer for showing the Crystal Report..
DataSet DataNew = new DataSet();
DataNew.ReadXml("F:\\LawrenceSoft\\VatDetails.xml");
DataTable dtReportSource = (DataTable)DataNew.Tables[0];
ReportDocument rdSample = new ReportDocument();
rdSample.Load("C:\\LawrenceSoft\\Sample.rpt");
rdSample.SetDataSource(dtReportSource);
crystalReportViewer1.Visible = true;
crystalReportViewer1.ReportSource = rdSample;
crystalReportViewer1.Refresh();
No comments:
Post a Comment