Results 1 to 4 of 4

Thread: [Answers] Report

  1. #1
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135

    [Answers] Report

    using the <%@ include=... %> directive (to include code from another file - great if you have standard elements that you want to use in more than one report) and the <%=...%> directive to evaluate an expression and embed it directly in the html.
    Putting my money where my mouth is and starting designing in ckeditor in a webview (as per Hank's post)
    then adding in a bit of CSS (check out Hank's other great recommendation for an online CSS editor here)
    and some NoSQL to grab the data
    and <%=...%> directives to include it in the html, I came up with the following:



    Probably not that tricky as an rsp page actually. Just work out the table layout in html then pull in the data. It would be worth you having a look at the report.rsp script in the Library - that is simpler than yours, but shows how to integrate NoSQL/SQL data commands and html.



    Q:
    What is the best way to create a report based on multiple tables (probably 5 or 6 tables)?
    A:
    In terms of the 'report' itself - what do you ultimately want to do with the report? If you can lay out a Page with the information you need displayed, you can use:

    Code:
    Lianja.showdocument("page:pagename?action=print")
    To save the Page as a pdf and from there print, share etc.



    Report sections are based on the Library file report.rsp.
    The code is included in the distribution and can be customized or used as a template -
    if you look at the Reports in lianjademo, they are actually WebView sections based on a variation of report.rsp, with the parameters passed in the URL.

    Report.rsp, does an actual USE of the table you specify in the attributes. You could use a virtual table based on a select from multiple tables as the table name, or an open cursor, since it checks first to see if the table is in use.
    The filter is used to construct a WHERE clause for the SELECT statement generated within report.rsp.
    It is just the <condition> part of the sql select ... where <condition> that you enter in the filter attribute. The report.rsp code builds the rest of the sql statement.



    Q:
    Is there a way to specify the report SQL statement instead of the table name as my report involves multiple tables?
    A:
    create a "local" Virtual Table that provides a view of the data you are interested in.
    As I have mentioned on many occasions, any sections that are based on WebViews are written as .rsp files and can be copied and extended to better suite your needs and customization requirements.



    Q:
    how can I display a PDF document in full screen? In my case, the PDF file is encrypted with a password.
    A:
    Install adobe reader and use the Activex is probably the easiest solution if you want to prompt for a password.
    If you create a "Form" programmatically in a delegate then add an activex to it that embeds Adobe reader, you can maximize the form on top of your app and call the methods in the activex control.
    This restricts you to windows as activex is a Microsoft specific technology.
    Also FYI, any file that you try to open in windows using Lianja.showDocument() will open using the file association based in the file extension. e.g. Lianja.showDocument( "file.pdf" ) will open the pdf file in Adobe reader whereas Lianja.showDocument("file.xlsx") will open it in Excel.



    Q:
    Can you tell me where I can find my .rsp file?
    My app is called, "akamaivoter" and the page with the report section is named "Walktest".
    I opened my app and then in the left panel, clicked on "Library". A list of folders and files displayed, some with the .rsp extension. However, none with the name of "walktest" or "akamaivoter". I also went to my windows explorer and did a search "walktest" as well as *.rsp and "akamaivoter" and didn't see it.
    A:
    There is no code as such.
    If its a report section then look at the attributes. These are postfixed onto lib:/report.rsp to generate the report.
    Its one report.rsp file for all reports and it resides in the library workspace.



    If all you want to do is generate a PDF file, do you realize that any HTML that is formatted in a WebView can be saved as a PDF file? This is all built-in.



    ​All topics in [Answers] alphabetically:http://www.lianja.com/community/show...ll=1#post12352
    Last edited by josipradnik; 2017-01-13 at 04:42.

  2. #2
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    Q:
    Let say I want to add a custom method, "Export_CSV", to a "Report" section that allow it to export the report data to CSV.
    I would then call this method programmatically from a click event
    A:
    You would not add a custom method to a page. You would just add the proc to the custom library for the page and call the proc from a section menu or section footer click.



    In Lianja v2.0 the ODBC Driver has had a major upgrade so that Lianja SQL Server can now work well with the latest version of Crystal Reports. So if you have an urgent reporting requirement you can use Crystal Reports which is pretty much the most popular report designer.



    Q:
    Do lianja have an alternative way of printing reports aside from webview?
    A:
    - Print as a PDF.
    - Generate as a text file and print the text file.
    - Generate PDF formatting yourself.
    Fix your paper size and it will scale properly.



    Q:
    What is with printing possibilitys. Are there thiongs like Reports? PDF-Export?
    A:
    The development view of the App Builder has print and pdf options from the 'Additional actions' (Instant Report). Sections have a print button optionally displayed in the header and the section.print() method can be called programatically. WebView Sections also have their own print() and printpreview() methods.



    Q:
    Can I generate a report in "section report" to select fields from different tables
    and the selection variables are used something like: SELECT table1.field1, TABLE1.FIELD2, TABLE2.FIELD1 FORM TABLE1, TABLE2, WHERE table1.field1 = TABLE2. FIELD1 = VAR1 AND table1.field1 can occupy a cursor on "SECTION REPORT"?
    A:
    The 'Report Section' is a 'WebView Section' and uses report.rsp (Library) to generate the report. You can see the code of the Library and also use it as a template for a custom report in a WebView Section. Report.rsp check the 'table' (attribute passed as a parameter) is already open. If the table does not open. So a cursor can be used, if open. Or a 'virtual table' (open or not, 'local' ConnStr)



    ​All topics in [Answers] alphabetically:http://www.lianja.com/community/show...ll=1#post12352
    Last edited by josipradnik; 2017-01-13 at 04:35.

  3. #3
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    Q:
    I have an issue with report which can only display detail record. I would like to know how i can generate report with header section containing information from parent table information (eg Order) and detail section containing information from child table (eg order details).
    A:
    Report Sections are single table (though can be a virtual table) reports. The report is generated by sending parameters to the report.rsp Lianja server page script in the Library.

    You could use report.rsp as a template for building your master detail report - copy it into your open App (using the 'Additional command' and have a look at the code. You can then call your modified code from a WebView Section.

    As a quick example, I added these lines to my copy of report.rsp (in my App and called mdreport.rsp) after the 'm_selected = select()' line:

    Code:
    use orders
    list html off for orderid = 10248
    use
    (You should check if the table is used() and save and restore the recno() accordingly or use SAVE DATASESSION / RESTORE_DATASESSION)

    My WebView URL is:
    mdreport.rsp?database=southwind&table=order_detail s&fields=*&filter=orderid=10248&heading=Order Details
    Which gives me a basic master-detail report:


    Using report.rsp as a template, you could customise the display to your requirements and add in additional parameters for the master table information and relationship to the details table.



    Report Sections are based on the 'report.rsp' script in the Library. For more information see the report.rsp section in the Report Options page in the Lianja wiki.
    The 'Lianja Demo' (lianjademo) desktop App has a local 'quickreport.rsp' customized report file that it uses in WebView Sections.



    Q:
    Is there a lianja/vfp code for me to know that a printer dialog box is cancelled or the cancel button is clicked?
    It is because every time I click the cancel button of the printer dialog box the printer is still printing but records are empty.
    A:
    No that is an operating specific dialog. There is no way to cancel a print operation from it as that is handled by your printer driver.



    Q:
    Then is it possible to print in lianja without showing the printer dialog box?
    payment.print(getprinter(),'portrait','native','', 'letter',1)
    A:
    I think that if you specify the name of the printer istead of getprinter(), the dialog will not be shown.
    E.g.:

    Code:
    payment.print('HP LaserJet 1022n','portrait','native','', 'letter',1)
    You can pick names of all your printers from APRINTERS() like that:
    Code:
    dimension aaa
    xx=aprinters(aaa)
    for ii= 1 to xx
        ?aaa(ii)
    endfor
    I do not know how to tell from that which one is set to default.



    For those of you who want to generate HTML formatted reports and print them here are a few good links that are worth reading.

    https://www.smashingmagazine.com/201...rint-with-css/
    http://stackoverflow.com/questions/3...per-size-pages
    https://github.com/delight-im/HTML-Sheets-of-Paper
    https://css-tricks.com/almanac/properties/p/page-break/
    http://stackoverflow.com/questions/1...ders-in-chrome

    wkhtmltopdf and wkhtmltoimage are open source (LGPLv3) command line tools to render HTML into PDF and various image formats using the Qt WebKit rendering engine. These run entirely "headless" and do not require a display or display service. These are free and open source so you can generate HTML reports and then convert and print them.
    http://wkhtmltopdf.org



    Q:
    I would like to know if any of you use the report tool to generate reports for the application.
    I tried from my way, I can't find the way to have a report with group heading information. I can just get report with group summary, report details and report summary. For example a report grouping details for Order will present these sections:
    - report header : title of report, printed date, page number
    - group introduction: order number, order date, customer number,...
    - report details: details informations of the order: product #, quantity, unit price, total
    - group summary: total amount for the order
    - report summary: total of all orders.
    So form my side, I can only produce header,report details, group summary, and report summary sections.
    A:
    lib:/report.rsp
    you can write your own rsp files and keep them in the library. It would not take much effort to write an invoice,rsp for generating invoices. I'm surprised nobody has.
    its such a common requirement, a page with a canvas section for entering customer info and another for entering line items which are refreshed into the invoice,rsp Webview is pretty simple to implement.
    A2:
    If you look at report.rsp in the library, you will see what with the right HTML, you can create just about anything you want. I've done a professional-looking invoice, starting with DreamWeaver. I actually put the virtual table/field names in the "fields" and did string substitution, etc., to make the job easier. It looks great (with adjustments to CSS, etc.)

    OTOH, for the main app at my day job, we have a lot, over 150, Crystal Reports, some of them flex (user picks the detail break related tables). For that we're looking at the Telerik Reporting Engine, because a) it claims to import Crystal Reports, b) it's still in development; c) it outputs to HTML (i.e., could feed a webview in Lianja) and d) engine distribution is free. We'll probably have to develop a .Net front-end web service so we can hit it from the Cloud Server, but that's a small price to pay for what we need. In theory we could use wwDotnetBridge (https://west-wind.com/wwDotnetBridge.aspx) to integrate, but don't want to confine ourselves to Windows servers for a variety of reasons (one of which is cost; the other is scalability by being able to put the reporting engine on a server other than the Cloud Server).

    That said, I think the Lianja Report Writer may end up being what we use. It's all a matter of timing in terms of our development process. My understanding from the various things Lianja has released about it is that a) design will be done using sections on a page; and b) underneath it will be VFP code (or other languages, I'm guessing), just as with reports.rsp. I see a lot of possibility for innovation, including flex reports, for this methodology, without much work required. Frankly, I'd rather VFP Report compatibility be the last on the list of requirements. VFP wasn't made for html reports, and we're in a different era now. For my usage (we don't use any VFP reports) running an .frx would be best looked at as a conversion program that creates the page and sections etc., added on to the Lianja Report Writer.



    Q:
    Is report grouping limited to a single field?
    If not, how would I write the expression? I tried separating the fields by commas e.g. field1, field2 but that didn't work. I also tried it as an expression like field1 + field 2 but that didn't work.

    Here's the second question.
    I tried to set the Group by to a field that is not in the field list of the Report Options and I got the same Run Time Error message. Must the field used in the Group By be one of the fields in the field list?
    A2:
    If you are looking for report.rsp ...
    There search for "group" (second checkbox for NEXT, first checkbox for PREVIOUS) or view all occurrences clicking FIND ALL



    You can figure out how report works and change its behaviour.

    A1:
    There is no code as such.
    If its a report section then look at the attributes. These are postfixed onto lib:/report.rsp to generate the report.
    Its one report.rsp file for all reports and it resides in the library workspace.



    ​All topics in [Answers] alphabetically: http://www.lianja.com/community/showthread.php?2717-Answers




  4. #4
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    Q:
    On click "Generate Report"-> Lianja.evaluate("report_htm()")


    In server script "report_htm.prg", I only have the following codes:
    Code:
    m.cFile = "htmlfile&(getpid()).htm"
    m.cStr=FileToStr("rpt_template.htm")
    m.nResult=StrToFile(m.cStr, m.cFile)
    I tested in the console Lianja.evaluate("_testreport()"), and it does create a file. However, when I run it a browser it fails. I also tried fwrite without success.

    A:
    Try this:
    Code:
    m.cFile = tmpnam(".htm")
    m.htmlrep = "c:\lianja\cloudserver\tenants\public\wwwroot\\zzzzw\rpt_template.htm"
    m.cStr=FileToStr(htmlrep)
    m.nResult=StrToFile(m.cStr, m.cFile)
    That saves to the default temporary directory: C:\lianja\server\tmp\ (can be changed in the Lianja Server Manager-> Settings) and specifies where to find the rpt_template.htm. (I'll check re the App dir, should be able to do that without hard-coding).




    All topics in [Answers] alphabetically: https://www.lianja.com/community/sho...ll=1#post13748

    These answers are also systematized on the site "Lianja developer": https://lianjadeveloper.wordpress.com/category/report/

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us