Creation and exporting from code

  • I would like to be able to click a button on a windows form and call a report, export this into a pdf and then email it to someone...without actually viewing the report. Is this possible? If so could someone point me in the right direction?

    Thanks,

  • You'll most likely want to use the web service to call the report render.  Basic steps would be:

    1. Call web service to render report, set the render type to be pdf.

    2. Accept the rendered report as a stream, then most likely put it to disk

    3. using whatever method you are using to manage the email side, create a new email and attach the report (ie from where you saved it to disk)

    4. send email.

    If you weren't so keen on writing too/so much code, you could use the WS again, but create a subscription, set it to run in the next 1 or 2 minutes and let RS handle the rendering and email.

    HTH,

     

    Steve.

  • I am very new to sql reporting so please bear with me. When you say "Call web service" what exactly do you mean? I can create web services, but I am not understanding this. Could you possibly give me an example of where you have done this?

    Thanks.

  • Well, you must create a web reference at web service of Reporting Service, and in the field URL, you must put http://server/ReportServer/ReportService.asmx?wsdl and you give it a name, for example RSService.

    Then, in your .aspx file, you import the web service, with the next sentence

    using YourApplication.RSService;

    You declare a variable of type ReportingService

    private ReportingService rs = null;

    and you create a instance of ReportingService object, you set up it the properties credentials, and Url.

    rs =

    new ReportingService();

    rs.Credentials = System.Net.CredentialCache.DefaultCredentials;

    rs.Url = "ReportServer/ReportService.asmx";

    and last, you must execute the report,

    byte[] data;

    data = rs.Render(ReportName,ReportFormat,null,null,null,null,null,out encoding,out mimeType,out parametersUsed,out warnings,out streamIds);

    The data object you can display it in a browser, text file, ....

    For more information, http://msdn.microsoft.com/library/default.asp?url=/library/en-us/RSPROG/htm/rsp_overview_1rvr.asp

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply