emailing FlexReports

Posted by: eamon9999 on 4 October 2017, 3:52 am EST

  • Posted 4 October 2017, 3:52 am EST

    I'm unable to find any example code for producing reports without using the report viewer.
    What I want to be able to do is to create a batch of pdf reports and email them to people, so that everyone gets their own report. So there should be a button that's clicked and then the reports are generated on the server and emailed to a list of employees.

    If you could point me in the right direction I'd much appreciate it. VB.net would be fantastic...(But not the end of the world if it's c#)
  • Replied 4 October 2017, 8:25 pm EST

    Hi Eamon,
    For this, you need to use WebApi Report Export Service. Please use the following code snippet for Exporting Report to PDF on the server.

    Public Sub generateReport(url As [String])

    Dim req As HttpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest)

    Dim res As HttpWebResponse = DirectCast(req.GetResponse(), HttpWebResponse)

    If res.StatusCode.ToString() = "OK" Then
    Dim path = "C:\Users\Admin\Downloads\Report.pdf"
    Using stream = System.IO.File.Create(path)

    res.GetResponseStream().CopyTo(stream)


    End Using

    End If

    res.Close()
    End Sub


    Where url="http://demos.componentone.com/ASPNET/c1webapi/4.0.20172.105/api/report/ReportsRoot/FlexCommonTasks/FlexCommonTasks.flxr/MultiValue DataBound Parameters/$report/export?exportOptions.format=pdf&exportFileName=MultiValue DataBound Parameters¶meters.pCategory=1"

    Please refer to the documentation for Configuring FlexReports WebAPI[1] and export Report[2] and Demo sample[3]

    Thanks,
    Manish Kumar Gupta

    [1]http://helpcentral.componentone.com/nethelp/c1webapi/Working%20with%20Reports.html
    [2]http://helpcentral.componentone.com/nethelp/c1webapi/Export.html
    [3]http://demos.componentone.com/ASPNET/WebApiExplorer
  • Replied 16 October 2017, 2:27 am EST

    Thanks for that.

    I can't seem to get my report path correct. I keep getting - The remote server returned an error: (404) Not Found.
    If my report path is

    ~\Content\ReportsRoot\rptMyReport.flxr

    What should I be putting in the URL? - I've tried lots of different combinations.

    One other query - what happens if you take down the WebApi Report Export Service ? It seems that my project will now be reliant on this always being available.

    Is there another way of doing this, where I'm not relying on your report export service?
  • Replied 17 October 2017, 8:15 pm EST

    think you are trying to use our publicly hosted reporting services, I would not recommend you use that in production as they are for demo purposes only.
    Also the report file ( .flxr) should be available on the Web Service so that it could be exported, as is the case with our Demo where FlexCommonTasks.flx is available on the same server where the export service is called.

    I would suggest you to host your own webservice and then use it to export the Report

    Please go through the configuration page of our Documentation to know how to add Report to Web Api

    http://helpcentral.componentone.com/nethelp/c1webapi/Working%20with%20Reports.html
  • Replied 27 July 2018, 3:11 am EST

    Please could you tell me how to password protect the report?

    I've tried a few things like: exportOptions.OwnerPassword but none of them seem to work.
    I also have no idea how to get a list of Export Options. I can't find that anywhere on your website.

    Thanks,

    Eamon
  • Marked as Answer

    Replied 5 August 2018, 6:04 pm EST

    Hi,
    We are extremely sorry for the delayed response.
    Please use userPassword for protecting your exported PDF.

    Format:
    api/report/{folder path}/{report name}/$report/export?exportOptions.format=pdf&exportFileName={file_name}&exportOptions.userPassword={password}

    Example Link:
    https://demos.componentone.com/ASPNET/c1webapi/4.0.20182.136/api/report/ReportsRoot/FlexCommonTasks/FlexCommonTasks.flxr/Simple%20List/$report/export?exportOptions.format=pdf&exportFileName=Simple%20List&exportOptions.userPassword=hello2

    ~Manish
  • Replied 1 February 2022, 3:44 am EST

    Sometimes the password does not work, or the user can put in an incorrect password.

    For example, the user specifies this password:
    Kilk#143

    But the document can not be opened with that password.
    Kilk
    appears to open the document.

    Is there a solution for this problem?
  • Replied 1 February 2022, 6:03 pm EST

    Hi Eamon,
    Thank you for reporting the issue. We are able to replicate the issue at our end and it has been forwarded to the concerned team for further investigation with the internal tracking id: C1Web-28911

    We will let you know as we get an update on this.

    In the meantime, please set the password without any symbols. Please use only the Alphabet and Digits.

    Regards,
    Manish Gupta
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels