Jump to content
Changes to the Jaspersoft community edition download ×

jgust

Members
  • Posts

    205
  • Joined

  • Last visited

  • Days Won

    1

Community Answers

  1. jgust's post in How to display one group twice per page in Jasper Reports was marked as the answer   
    You cannot display data twice unless it exists twice.
    What you can do is update your dataset and UNION the results to itself.  During that process, you may want to add a hardcoded column like REC_TYPE to help you identify where the data should print.
    select 'top' as REC_TYPE, field1, field2 from My_Tableunionselect 'bottom', field1, field2 from My_Table [/code] 
  2. jgust's post in Bypass Jasperstudio report building was marked as the answer   
    Here is a low-effort way to create a CSV-designed report
    1. Create a new blank report.
    2. Modify the page format to be Ledger Landscape (you want as much canvas space as possible)
    3. Click on the Detail band and change the layouts to "Spreadsheet Layout"
    4. Repeat step 3 for the Column Header band.
    5. Repeat step 3 for the Title band
    6. Drag the fields from the Outline to the Detail band
    7. Move the auto-created static text fields from the Column Header band to the Title Band
    8. Delete the Column Header band
    9. Run and export the report as CSV
    10. Profit

    The report canvas should look something like this on the design tab

    The width and depth are of no concern to the CSV export format.  This is hard to read but you can use the Outline to find and select fields if modifications are needed.
  3. jgust's post in How to hide label in main report if a subreport further down is empty? was marked as the answer   
    You can move the title to each subreport and then suppress it if the title has already been printed.
    To identify if it has already been printed for each subreport pass a flag (vTitleHasPrinted) back to the main report.  Then pass that flag to each subsequent subreport.
  4. jgust's post in use Sum, convert, MIN, MAX was marked as the answer   
    Assuming the SQL is correct you should provide an alias for each column by adding "as" followed by the alias name.
    select convert(varchar(10), MIN(DateBeginPeriod), 103) as StartDate , convert(varchar(10), MAX(DateEndPeriod), 103) as EndDatefrom UnmeteredConsumption[/code] 
  5. jgust's post in URGENT How can i count only once the rows with same id? URGENT was marked as the answer   
    Create a variable with a class type of integer and a "Distinct Count" calculation.
    In the expression add the field you would like a distinct count of.

    Finally, create a text field on the canvas to display the value of the expression.

     

  6. jgust's post in error while calling pl/sql function from query was marked as the answer   
    Thank you for the clarification.
    I was able to recreate the issue by setting the language to SQL and using a custom function in the query.

     
    The solution was to change the language to PLSQL.  Once I did that I was able to read the fields.

     
  7. jgust's post in Preventing my group from being split up was marked as the answer   
    @jcrozier
    >> Curious if it could have been controlled on the jasper side though
    You will need to add a sort to the report.  In other report engines grouping and sorting is one transaction.  In Jasper, it is two.

     
    With Sorting


     
    Without Sorting


  8. jgust's post in Group Repeating was marked as the answer   
    You will need to add a sort to the report.  In other report engines grouping and sorting is one transaction.  In Jasper, it is two.


     
    With Sorting


     
    Without Sorting


     
  9. jgust's post in PDF Export : How to set Title/Author/Subject/Keyword was marked as the answer   
    If you want all PDF exports to have the same values you can set the values using the PDF export properties in Jasper Studio.

     
    If you need each report to have its own set of values then you can add the property name to the jrxml file and set it there.


  10. jgust's post in Is it possible to have different styles in one element in Jaspersoft? was marked as the answer   
    Yes, you can do this by setting the markup attribute on the text field or status text object.
    http://jasperreports.sourceforge.net/sample.reference/markup/

  11. jgust's post in Use report name in report was marked as the answer   
    Provided you put the report name in the report name field you can use the following built-in parameter:
    $P{JASPER_REPORT}.getName()[/code] 
  12. jgust's post in Can i change my fields name? was marked as the answer   
    I don't know the answer to your specific question if it will effect in html and javascript.  I will say that in my experience that it is always better to bring in the data correctly and clearly if you can help it.  You can do this by assigning an alias in SQL.
    SELECT employee.name AS EMP_NAME ,project.name AS PROJ_NAME ,department.name AS DEPT_NAMEFROM employeeINNER JOIN project ON project.id = employee.idINNER JOIN department ON department.id = employee.dept_id[/code] 
  13. jgust's post in Does Use of Stored Procedures Improve Security? was marked as the answer   
    My shop solely uses procedures for reporting 700+ reports.
    Benefits:
    Data logic is not tied to the presentation object.
    This becomes important when/if you ever change the report engine.  In the last 10yrs, we went from Cognos, SAP BOBI, Crystal Report, and finally working on Jasper.  Having to rewrite 800+ reports all having their own tables/views would be a challenge.  It is difficult enough now having to deal with the presentation and scripting (formula vs expressions) differences. The procedure can address some presentation instead of having a formula do it.
    Consider having a UserFname and UserLName field.  You could combine that in the procedure as User_FullName so that you don't need to write another bit of code in the engine to combine them together.  It's easy enough to do it in the engine but when you have 800+ reports these easy things cost you time especially when/if you change the engine and have to do it all over again.  Security
    You can create a read-only report user that has permission to execute specified report procedures.  This moves a level of security to the db while you could also add another level on top of the engine. Performance Tuning
    Depending on the db engine you will have more control of how the SQL is executed then you would have if you let the engine make all of the decisions.  One scenario that comes to mind is we have a scaling issue.  Some of our reports take 5+hr to run due to the complexity and amount of data.  We were able to analyze the issue with our dba and identify that we could rewrite the query using CTE's and also add an Oracle HINT to make a suggestion to the optimizer for a better approach.  The report now takes under 2hrs.
  14. jgust's post in Multiple IF-ELSE was marked as the answer   
    In Jasper the supported java IF statement is called a Java Ternary Operator.
    Here is the format:      (expression) ? value if true: value if false
    Example:
    $F{Column1}.equals( "A" ) ? "Text 1" : $F{Column2}.equals( "B" ) ? "Text 2" : $F{Column3}[/code]In case your ternary gets more complicated here is a link to an article on Java basic operators.  This will be helpful if you need to add an AND (&&) or and OR (||) condition.
    https://www.tutorialspoint.com/java/java_basic_operators.htm
  15. jgust's post in Imprimir Cabeçalho do Relatório o Sem Registro was marked as the answer   
    Você pode definir o valor "Quando nenhum tipo de dados" for "Todas as seções sem detalhes" no nível do relatório.

    Ou você pode configurá-lo para "Seção sem dados", somente a banda "Sem dados" será exibida.   
  16. jgust's post in Show hide with Table was marked as the answer   
    Let's say you have a boolean parameter called $P{ShowTableA} with a default value of 'true'.
    <parameter name="ShowTableA" class="java.lang.Boolean"> <defaultValueExpression><![CDATA[true]]></defaultValueExpression> </parameter>[/code]Depending on the value of that parameter you can use the "Print When Expression" on the subreport to suppress or show it.
     
    This condition will Show Table A
     
    $P{ShowTableA}.equals( true )[/code] 
    This condition will show Table B
     
    $P{ShowTableA}.equals( false )[/code] 
  17. jgust's post in Only 1 value data is appearing, if I give 2 values in parameter. was marked as the answer   
    I use that syntax in most of my reports.  Here is how I use it.
    SELECT L.LEA_ID , L.LEA_NAME , C.CAMPUS_ID , C.CAMPUS_NAME FROM SCH_PEIMS_APP.V_R_PDM_LEA L INNER JOIN SCH_PEIMS_APP.V_R_PDM_CAMPUS C ON L.ACAD_YR = C.ACAD_YR AND L.COLL_NAME = C.COLL_NAME AND L.SUBM_NUM = C.SUBM_NUM AND L.LEA_ID = C.LEA_ID WHERE L.ACAD_YR = $P{psEnter Academic Year} AND L.COLL_NAME = $P{psEnter Collection Name} AND L.SUBM_NUM = $P{psEnter Submission Number} AND L.LEA_ID = $P{psEnter Organization ID} AND ($X{IN,C.CAMPUS_ID,PM_M_CAMP_ID} OR $X{IN,'* All Campuses',PM_M_CAMP_ID})[/code]If you're not getting the right data then I would say the issue may be that your array parameter may not have the expected values.  If this is the case then you can create an expression to display all of the values in your array.  This may help to verify.
    String.join(", ", $P{PM_M_CAMP_ID})[/code]
  18. jgust's post in variable was marked as the answer   
    Use the "matchs" method to find if the field is numeric using a regex expression $F{TextMiles}.matches( "^[-+]?\b\d+[\.]?[\d+]" )
    After that you can use DOUBLE_VALUE, FLOAT_VALUE, or INTEGER_VALUE built-in functions to convert the value.
    Here are the resulting IF expressions.

    Double:
    $F{TextMiles}.matches( "^[-+]?\b\d+[\.]?[\d+]" ) ? DOUBLE_VALUE( $F{TextMiles} ) : 0
    Float:
    $F{TextMiles}.matches( "^[-+]?\b\d+[\.]?[\d+]" ) ? FLOAT_VALUE( $F{TextMiles} ) : 0
    Integer
    $F{TextMiles}.matches( "^[-+]?\b\d+[\.]?[\d+]" ) ? INTEGER_VALUE( $F{TextMiles} ) : 0
     
  19. jgust's post in How can I have a dynamic page footer? was marked as the answer   
    You can't have multiple page footers so a possible workaround would be to create multiple group footers with a print when expression tied to the page number.  You can set the group footer position to Force at Bottom.
    Another possibility is to have a subreport in the page footer using empty row as the data adapter.  You can then pass all your data and format in the subreport as needed.
×
×
  • Create New...