Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Export to excel - filename should be constant?

Hi to all,

I'm using Crystal Report11.5,Asp.net2.0-C#.

I'm using this code to export the records from crystal report to excel file

MemoryStream oStream; // using System.IO

oStream = (MemoryStream)

boReportDocument.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);

Response.Clear();

Response.Buffer = true;

Response.ContentType = "application/vnd.ms-excel";

Response.BinaryWrite(oStream.ToArray());

HttpContext.Current.ApplicationInstance.CompleteRequest();

This is working fine but it create a file name like

CA416XHE.xls, CAS1C10R.xls i want to set this like

ExportExcel.xls, how to do this.?

Former Member
replied

Hello,

ExportToStream has a filename property where you can set the file name you require.

[Click|http://msdn.microsoft.com/en-us/library/ms227570.aspx]

ExportToHTTPResponse has the same:

[Click|http://msdn.microsoft.com/en-us/library/ms227586.aspx]

Both of these properties are Microsoft properties outside of the Crystal Reports SDK.

We do recommend using ExportToHTTPResponse for security reasons.

[Click|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes.do]

Elaine

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question