Make it possible for you to write your own export function

Posted by: wilfreds on 14 September 2017, 6:52 pm EST

    • Post Options:
    • Link

    Posted 14 September 2017, 6:52 pm EST

    [activereports_archive]This is how it works:

    I have service running on a server machine that returns an AR report on the request from the client machine.

    The client machine retrieves the report and loads it in a SectionReport.

    Dim rpt As New GrapeCity.ActiveReports.SectionReport
    

    …some code

    rpt.Document.Load(ms)
    Me.Viewer1.Report = rpt
    

    That works fantastic and the user is presented with a beautiful report perfect for printing.

    However, here is the problem. The user wants to move the numbers over to excel so that the person can work on the data.

    For that, we have the GrapeCity.ActiveReports.Export.Excel.Section.XlsExport. The problem is all the unwanted “things” that is also put in the excel sheet. You have unwanted columns, headers, footers pagination and so on. So the user has to spend considerable time cleaning up the excel sheet to use the data. In addition, it has to be repeated every time.

    My suggestion is to give us access to the numbers and data inside the report document so that we can write our own export. Something like this:

                    For Each page As Page In rpt.Document.Pages
                        For Each section As Section In page.Sections
                            For Each row As Row In section.Rows
                                For Each col As Column In row.Columns
                                ...get the data
                                Next
                            Next
                        Next
                    Next
    
    

    Is that possible? Can someone from C1 comment on this?

    I have also written a suggestion feature request.

    Thanks,

    Wilfred[/activereports_archive]

  • Posted 14 September 2017, 6:52 pm EST

    [activereports_archive]Wilfred,

    If you wish to make any modifications to your report before exporting it to excel then you can either make use of the SpreadBuilder API to completely handle the excel export or run your report for a second time before you export it to excel. You may want to check the following blog articles which provide explanation on both these approaches:

    http://arhelp.grapecity.com/2013/03/15/hide-duplicate-page-headers-while-exporting-report-to-excel/

    http://arhelp.grapecity.com/2013/04/19/automatically-export-a-section-report-to-excel-using-spreadbuilder-api/

    Let me know if you have any doubts.

    Regards,

    Sankalp[/activereports_archive]

  • Posted 14 September 2017, 6:52 pm EST

    [activereports_archive]Sankalp,

    Thanks for your suggestions.

    I have already looked at those.

    Having to query the report server again before the export is not a good solution. Especially if it is a long running report. And by that time the numbers may have changed. And building the export as the report is generated was something I was hoping to avoid. Needing to send more data over the wire.

    So, back to my suggestion.

    Why not give us access to the data from the generated document. We know it is there. It is just “hidden”. The included AR export to excel function is using the data from the document to produce an excel report. So why not give us the same access to the data to write our own?

    Any chance that you will add this feature in the near future?

    Regards,

    Wilfred[/activereports_archive]

  • Posted 14 September 2017, 6:52 pm EST

    [activereports_archive]Wilfred,

    If you simply wish to get the data out of the report then you can do so by handling the format event of the detail section and get the current value being displayed in any control placed inside the detail section.

    Can you please elaborate on how you want this feature to work? Do you only want some way to get raw data from the report? If yes then it can be done as suggested in the last paragraph. Some description about the whole process will make your requirements clearer to me. Also can you provide a use case for requiring this feature? This informati0n will also help the product management to decide about whether or not this feature can be provided.

    Regards,

    Sankalp[/activereports_archive]

  • Posted 14 September 2017, 6:52 pm EST

    [activereports_archive]Sankalp,

    Yes, that is exactly what I want. I need to get the raw data inside the report document.

    I have two use cases for this.

    Use case 1.

    I can write my own generic export function. Without having to handle the format event of the detail section in every report we make. That way it will work with every report we have already made and will make in the future.

    In our shop, we have a separate server that makes all the reports. The client request a report and receives the report as a Report.Document over the wire. If the server report generator also need to handle the format event to collect data it only means we have to send more data over the wire and making things more complicated. Remember, the client has no access to the format event as all work is done on the server.

    I want the process of making a report to be as clean and simple as possible. I do not want the person who designs the report having to worry about putting code inside the format event to collect data.

    Use case 2.

    I can write a very cool copy and paste function. It works like this. The user uses the mouse to select an area of the report. Drawing a box around the area. Based on the position of the selected area I can collect all the text and numbers inside that area. The user can then select copy, and then paste the data directly into excel.

    To implement use case 1 and 2 I need to be able to get to the raw data inside the report.document. The more information I can get the better. Like position, the text and the name of the field. In addition, maybe the section and type of the field. However, as a very minimum I need the position and the text.

    Hope that makes it clearer.

    Regards,

    Wilfred[/activereports_archive]

  • Posted 14 September 2017, 6:52 pm EST

    [activereports_archive]Wilfred,

    Thank you for providing the detailed information. I have opened a new Feature Request Case 177420 for the development team to implement this feature. However I cannot provide you an ETA on when it might be available. I have added you as an affected user to this case and you will be notified if this feature would be added in future.

    Regards,

    Sankalp[/activereports_archive]

  • Posted 14 September 2017, 6:52 pm EST

    [activereports_archive]Wilfred,

    As per the update which I have got from the development team, you can still access data from the RDF document. For example, in the form’s code behind, you can access all the controls on the document, page by page by using the following code:

    [csharp] foreach (Page p in rpt.Document.Pages)

    {

    var pageItems = p.CanvasItems;

    foreach (CanvasItem _cItem in pageItems)

    {

    // Get info from _cItem

    }

    }[/csharp]

    Here rpt is the report object. Therefore Case 177420 has been resolved and won’t be implemented. Let me know if you have any doubts.

    Regards,

    Sankalp[/activereports_archive]

  • Posted 14 September 2017, 6:52 pm EST

    [activereports_archive]Sankalp,

    Thanks.

    That was good news. Exactly what I was looking for.

    Regards,

    Wilfred[/activereports_archive]

  • Posted 14 September 2017, 6:52 pm EST

    [activereports_archive]Wifred,

    Thank you for the update. Glad to know that the suggestion worked for you.

    Regards,

    Sankalp[/activereports_archive]

  • Posted 2 April 2019, 2:45 pm EST

    Hi Sankalp,

    I have got a same problem like what is mentioned here in this forum. I have to eliminate page header in all the pages except page 1 while exporting to XLS and XLSX. While viewing the report, I am fine with all page headers n all pages.

    After viewing, I am clicking on export and using the method XLS.Export(ReportDocument, “Filename”).

    I want to update this ReportDocument in such a way so that I can show Page header only in top of the XLS page and rest all should come as a normal data. If I do it in PageHeader_Format event, then PageHeader doesn’t come after first page while viewing (before exporting).

    I hope my problem would be understood to you.

    Please suggest me the same.

    Thanks

    Gaurav

Need extra support?

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

Learn More

Forum Channels