Crystal Report Viewer - software restriction of file format settings

In Crystal Reports Viewer (2008) for ASP.Net, when you click the Export button, the Export dialog box opens with the File Format options:

  • Crystal Reports (RPT)
  • Pdf
  • Microsoft Excel (97-2003)
  • Microsoft Excel (97-2003) Data Only
  • Microsoft Word (97-2003)
  • Microsoft Word (97-2003) Editable
  • Rich Text Format (RTF)
  • XML

etc..

Does anyone know how to remove some of these options so that end users do not see it?

+4
source share
6 answers

We ran into the same problem and ended up working with our own export page and limited it there.

It works great, but I expected more from Crystal Reports!

+3
source

From what I could find, you could try to create your own export button option by removing this button and adding your own asp page. You will need to start by dragging the button onto the page and double-clicking on it to automatically generate the code. From there add code

crystalReportViewer1.ExportReport () 

Once this code is in it, the default settings for the export options will be used, however, if you want to change the export options in this button, you need to manually encode it.

 ' Declare variables and get the export options. Dim exportOpts As New ExportOptions() Dim diskOpts As New DiskFileDestinationOptions() Dim excelFormatOpts As New ExcelFormatOptions() exportOpts = Report.ExportOptions ' Set the excel format options. excelFormatOpts.ExcelTabHasColumnHeadings = true exportOpts.ExportFormatType = ExportFormatType.Excel exportOpts.FormatOptions = excelFormatOpts ' Set the export format. exportOpts.ExportFormatType = ExportFormatType.Excel exportOpts.ExportDestinationType = ExportDestinationType.DiskFile ' Set the disk file options. diskOpts.DiskFileName = fileName exportOpts.DestinationOptions = diskOpts Report.Export() 

MSDN SITE

This link gives you the same code as above. It shows how to do this in Visual Basic code. so in your aspx.vb code you have to manually enter the types of formats you want.

+1
source

You may be able to control export settings by deleting export DLLs. Find crxf _ *. Dll in the Business Objects \ Common \\ bin directory.

+1
source
  <asp:ImageButton Width="20px" Height="20px" ID="btnPdf" runat="server" OnClick="btnExport_Click" ImageUrl="~/Images/PDF.png" AlternateText="Export To PDF" CssClass="AddedButton" /> <asp:ImageButton Width="20px" Height="20px" ID="btnXls" runat="server" OnClick="btnExport_Click" ImageUrl="~/Images/XLS.png" AlternateText="Export To Excel" /> <asp:ImageButton Width="20px" Height="20px" ID="btnDoc" runat="server" OnClick="btnExport_Click" ImageUrl="~/Images/DOC.png" AlternateText="Export To Word" /> 

try the following:

  <CR:CrystalReportViewer ... HasExportButton="false" HasPrintButton="False" > <asp:ImageButton Width="20px" Height="20px" ID="btnPdf" runat="server" OnClick="btnExport_Click" ImageUrl="~/Images/PDF.png" AlternateText="Export To PDF" CssClass="AddedButton" /> <asp:ImageButton Width="20px" Height="20px" ID="btnXls" runat="server" OnClick="btnExport_Click" ImageUrl="~/Images/XLS.png" AlternateText="Export To Excel" /> <asp:ImageButton Width="20px" Height="20px" ID="btnDoc" runat="server" OnClick="btnExport_Click" ImageUrl="~/Images/DOC.png" AlternateText="Export To Word" /> C# code: protected void btnExport_Click(object sender, EventArgs e) { // Stop buffering the response Response.Buffer = false; // Clear the response content and headers Response.ClearContent(); Response.ClearHeaders(); try { string senderID = ((ImageButton)sender).ID; if (senderID == "btnPdf") reportDocument.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, Page.Title); else if (senderID == "btnXls") reportDocument.ExportToHttpResponse(ExportFormatType.ExcelRecord, Response, true, Page.Title); else if (senderID == "btnDoc") reportDocument.ExportToHttpResponse(ExportFormatType.WordForWindows, Response, true, Page.Title); // There are other format options available such as Word, Excel, CVS, and HTML in the ExportFormatType Enum given by crystal reports } catch (System.Threading.ThreadAbortException) { //The issue has been identified and logged under Problem Report ID //ADAPT00765364. The error is likely caused because Response.End() is used inside the //ExportToHttpResponse() method. //It is a known issue that Reponse.End() causes the thread to abort. This is by design. //See Microsoft KB312629 Article for more info. } catch (Exception ex) { //error management } } 
+1
source

See the answer below to remove unwanted exports. Variant from Crystal Reports

Display PDF and Excel export options in Crystal Reports?

+1
source
  using (ReportClass rptH = new ReportClass()) { rptH.FileName = @"C:/Report/crJournal.rpt"; //Your rpt file path // if you put your rpt file on Bin then you need to write only rpt file name rptH.Load(); rptH.SetDataSource( ds );// Provide Dataset for report : Ds is DataSet rptH.ExportToDisk(ExportFormatType.Excel, "Give Output file path"); } 

This code works defenetly:

0
source

Source: https://habr.com/ru/post/1303137/


All Articles