Visual Studio 2005 and Crystal Report exporting

Greetings. I was wondering if there's a way to export a report into a pdf directly, without the preview display and having to press the export button manually? I want the page to open a pdf straight away.
In particular, I mean can it be done with just the aspx-page, without having to write code in the .cs-file? And if I do have to write the code, why doesn't it work like it used to? I can't seem to be able to create an object from the .rpt file, export it into a file and write the file into the response stream. It just refuses to find the .rpt, even though it is included in the project.
[608 byte] By [Vesa] at [2007-12-16]
# 1

i think all you need to do is call the ExportToStream method on the ReportDocument object. it'll look something like this...


//stream output pdf

System.IO.MemoryStream m_stream = new System.IO.MemoryStream();

// Get the export stream

m_stream = (System.IO.MemoryStream)this.reportSource.ReportDocument.ExportToStream(ExportFormatType.PortableDocFormat);

m_stream.Position = 0;

Response.ContentType = "application/pdf";

Response.Clear(); //make sure there's no extraneous content

Response.BinaryWrite(m_stream.ToArray());

Response.Flush();

m_stream.Close();

reportSource.ReportDocument.Close();

//*********************************************

Response.End();



dagnar at 2007-9-9 > top of Msdn Tech,Visual Studio,Crystal Reports for Visual Studio...

Visual Studio

Site Classified