开发者

How do I set default pdf file name in crystal viewer while exporting it?

I have devoloped an application in Visual Foxpro 9.0 using Crystal reports 10 as report designer. Database in SQL 2005. For report preivew, I have used Crystal Report Viewer 10. My problem is, while exporting it in PFD through Report viewer, How do I set default File name for the exported file? By default it gives name of rpt file as default name o开发者_如何学Cf PDF file.


You can do it by setting the report tile which the default file name you wish to have.

cr.SummaryInfo.ReportTitle = "Default File name you want"


Try setting the ReportDocument.SummaryInfo.ReportTitle property prior to the export - I think this is used as the default name.


This is dangerous, but you can try setting CrystalReportViewer1.ID = "ExportName"; where CrystalReportViewer1 is the control specified in your .aspx file(in my case atleast)

<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" 
    AutoDataBind="True" EnableDatabaseLogonPrompt="false" 
    onunload="CrystalReportViewer1_Unload" />

<%@ Register assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" namespace="CrystalDecisions.Web" tagprefix="CR" %>

Hope this helps!

UPDATE

Rather than trying the above, call the ExportToHttpResponse method. In my case, I have

cryRpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "Friendly Document Name here");

The first parameter of ExportToHttpResponse() is selecting the type of export format you need, i.e. PDF. (ExportFormatType)

The second parameter is your UI Page Response unit that is sent to the client. You can just use Response here. (HttpResponse)

The third parameter is whether you need the report to be sent as an attachement to the client, which you do - so the boolean value here of is True. (boolean)

The forth parameter is a string which is the name you want the file to be named.

Hope this helps!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜