cancel
Showing results for 
Search instead for 
Did you mean: 

Export to excel - filename should be constant?

Former Member
0 Kudos

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.?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Answers (0)