Home / ASP.NET Forums / Advanced ASP.NET / Crystal Reports / How to export multiple Crystal Reports into one pdf format? How to export multiple Crystal Reports into one pdf format? Here Mudassar Ahmed Khan has explained with an example, how to export and download Crystal Report in Word, Excel, PDF and CSV file formats on Button Click in ASP.Net using C# and VB.Net. TAGs: ASP.Net, Crystal Reports. When exporting from Crystal Reports to a PDF file, the fonts decrease in size and barcodes may scan. Solution: This is not caused by IDAutomation fonts, but is a known issue with Crystal Reports where it reduces the font when exporting to a PDF file. Need help to export crystal report to PDF format. Asked By Jack Reacher 10 points N/A Posted on -. I need some help and tips on how to export crystal report to pdf format and have it directly saved at the local folder of our website and then have it as an email attachment sent viat SMTP.
![]()
Crystal Reports is a welcome subjects for blog posts. I still do like the product, my users are very happy with the results, the report editor is not that bad to work with and the components integrate well into a solution. But Crystal documentation is an absolute disaster. I wanted to add some functionality to my basic export routine. The only thing was adding export to Excel and to html. This functionality is present in the basic Crystal installation but how to use it is something which took me really a lot of Googling. The answers were not on the Crystal site but in the dungeons of the usenet. Let me share what I found.
On of the things I learned is that you have to Close() a report after exporting. This was not in the official Crystal example. I havn't measured the effect but it doesn't harm.
Exporting to Excel turned out to be just a matter of setting the right content type. This type turned out to be application/vnd.ms-excel. I had expected application/msexcel, as a nice sibling to application/msword. https://renewaus829.weebly.com/blog/emperor-handbook-meditation-new-translation-bible. Exporting to Excel has some extra format options but you can do without them for a basic export. I'll leave these for another post.
To get the exporting to html to work took some things which are next to ridiculous, but I got it working. You have to set some format options. In these options you set the root directory and the filename. This directory-filename pair should be identical to the export filename passed to the report. The result will be an html formatted report, but in a 'slightly' different location. To find the result you have to do some tricks. When Crystals creates a report is does create a temporary .rpt file. This file is stored in the windowstemp dir, it's name is a guid. When Crystal creates the exported report it creates a directory in the root directory supplied with the name of this guid. In this directory the report will be created, using the filename supplied. Thank goodness the name of the temporary file is available in the FilePath property of the report. This snippet demonstrates the workaround:
string[] fp = selectedReport.FilePath.Split('.ToCharArray());
To sum it all up :
protected void exportReport(CrystalDecisions.CrystalReports.Engine.ReportClass selectedReport, CrystalDecisions.Shared.ExportFormatType eft)
string contentType =';
// Make sure asp.net has create and delete permissions in the directory string tempDir = System.Configuration.ConfigurationSettings.AppSettings['TempDir']; string tempFileName = Session.SessionID.ToString() + '.'; switch (eft) { case CrystalDecisions.Shared.ExportFormatType.PortableDocFormat : tempFileName += 'pdf'; contentType = 'application/pdf'; break; case CrystalDecisions.Shared.ExportFormatType.WordForWindows : tempFileName+= 'doc'; contentType = 'application/msword'; break; case CrystalDecisions.Shared.ExportFormatType.Excel : tempFileName+= 'xls'; contentType = 'application/vnd.ms-excel'; break; case CrystalDecisions.Shared.ExportFormatType.HTML32 : case CrystalDecisions.Shared.ExportFormatType.HTML40 : tempFileName+= 'htm'; contentType = 'text/html'; CrystalDecisions.Shared.HTMLFormatOptions hop = new CrystalDecisions.Shared.HTMLFormatOptions(); hop.HTMLBaseFolderName = tempDir; hop.HTMLFileName = tempFileName; selectedReport.ExportOptions.FormatOptions = hop; break; }
CrystalDecisions.Shared.DiskFileDestinationOptions dfo = new CrystalDecisions.Shared.DiskFileDestinationOptions();
dfo.DiskFileName = tempDir + tempFileName; selectedReport.ExportOptions.DestinationOptions = dfo; selectedReport.ExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;
selectedReport.Export();
selectedReport.Close();
string tempFileNameUsed;
if (eft CrystalDecisions.Shared.ExportFormatType.HTML32 || eft CrystalDecisions.Shared.ExportFormatType.HTML40) { string[] fp = selectedReport.FilePath.Split('.ToCharArray()); string leafDir = fp[fp.Length-1]; // strip .rpt extension leafDir = leafDir.Substring(0, leafDir.Length – 4); tempFileNameUsed = string.Format('{0}{1}{2}', tempDir, leafDir, tempFileName); } else tempFileNameUsed = tempDir + tempFileName;
Response.ClearContent();
Response.ClearHeaders(); Response.ContentType = contentType;
Response.WriteFile(tempFileNameUsed);
Response.Flush(); Response.Close();
System.IO.File.Delete(tempFileNameUsed);
}
Which is pretty straightforward and even works. With a lot of thanks to the many people on the web who have also been strugling with this.
Peter
With the release of Crystal Reports for Visual Studio 2010 Production Release Now Available (CRVS2010), I wanted to update the Wiki Available Export Formats, Crystal Reports 9.1 to Crystal Reports 2008 with info for CRVS2010. Unfortunately, CRVS2010 being somewhat of a different beast (it’s not a bundle, it’s not a stand-alone version), I am thinking of decoupling from the Wiki and document exports in CRVS2010 in this bog.
Crystal Reports Export Options
In CRVS2010, we have three viewers; Windows, Web and WPF. Each of the viewers has 10 default export formats available from the viewer export button. A new feature of CRVS2010 is the ability to modify the available export formats from the viewer export button. The following C# sample code demonstrates how to set the CrystalReportViewer to export only to PDF and Excel file formats:
How To Export Crystal Report In Pdf Format Using Vb.net
Similarly, other supported export formats (see below) can be added to the viewer export button. For more details see KBase 1498827 – How to set the list of available export types in the .NET CrystalReportViewer control. And of course as always, the export formats can be exported to using code only. For samples of export applications see Crystal Reports for .NET SDK Samples.
https://renewaus829.weebly.com/blog/download-lagu-soundtrack-transformers-3-dark-of-the-moon. There are two new export file formats available in CRVS2010; XLSX and RPTR. For a demonstration of export to XLSX, see the demo Overview of Export to XSLX with Crystal Reports for Visual Studio 2010.
RPTR reports are Crystal reports that can be viewed with report viewer applications, but cannot be modified with the SDK or opened by report designer applications. The definition of an RPTR report cannot be modified, so you cannot use this SDK to set the data source location of an RPTR through the database controller. However, you can refresh the data of an RPTR report at run time by refreshing the report in a viewer.
Crystal Reports (*.RPT)
Adobe Acrobat (*.PDF) Character Separated Values (*.CSV) Microsoft Excel (97-2003) (*.XLS) Microsoft Excel (97-2003) Data-Only (*.XLS) Microsoft Excel Workbook Data-Only (*.XLSX) Microsoft Word (97-2003) (*.DOC) Microsoft Word (97-2003) – Editable (*.RTF) Rich Text Format (RTF) (*.RTF) XML (*.XML) HTML32 (*.HTML) HTML40 (*.HTML) RPTR (*.RPTR) Text (*.TXT) Tab Separated Text (*.TXT)
The export types highlighted in the above list are available in the Crystal Reports viewer. Export types in black are only available via calling the appropriate export API.
For more information, don’t forget to search the SAP KBase, the SAP Crystal Reports, version for Visual Studio and make sure to visit the SAP Crystal Reports for Visual Studio web page.
I also highly recommend looking at the youtube video by Brian Bischof, Crystal Reports .NET 2010 Quickstart Guide.
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |