Jump to content
Changes to the Jaspersoft community edition download ×

C-Box

Members
  • Posts

    910
  • Joined

  • Last visited

Community Answers

  1. C-Box's post in How to give different style properties for a single field? was marked as the answer   
    When you use Arial for the textfield font you will have to create a FontExtension for Arial to embedd this one also in the generated PDF file. (I guess your "courier workaround "doesn't look as wanted!?!? ;-) ) 
    hth again + regards
    C-Box
     
  2. C-Box's post in Videos or practical examples on doing math with variables in Jaspersoft Studio was marked as the answer   
    if you use some BigDecimal types for your measures you must be aware of the RoundingMode and the expected scale. ... eg following divides by 3 and rounds half up and set the scale to 2 digits after the decimal separator:
    $V{CORN1_MEASURE}.divide(new BigDecimal(3), 2, BigDecimal.ROUND_HALF_UP);[/code]Be aware that your measure isn't null.... otherwise make a simple If-Then-Else Check before:
    $V{CORN1_MEASURE} == null ? BigDecimal.ZERO : $V{CORN1_MEASURE}.divide(new BigDecimal(3), 2, BigDecimal.ROUND_HALF_UP);[/code]hth + regards
    C-Box
  3. C-Box's post in Hi guys how to put ordinal numbers in the day? was marked as the answer   
    Hmmm something you are doing wrong... I just created a test with the EXACT suggested expressions by my first post:
    Works like a charm:


    see JRXML attached.
    hth + regards
    C-Box

  4. C-Box's post in How to set classpath for libraries of Jasper Report in Java? was marked as the answer   
    What about using wildcards in your cp parameter?
    https://stackoverflow.com/questions/219585/including-all-the-jars-in-a-directory-within-the-java-classpath
    I would put all needed jasper and external library jars into one subfolder "lib" and just use the wildcard syntax to include them.
    Which jars really needed depends on what you are doing... if you want to export to excel you would need apache-poi libs as well... if you want to export to pdf you will need itext... so it isn't really defined ... a minimal set of libs are listed here for example: https://stackoverflow.com/questions/25069522/jars-needed-for-jasperreports
    hth + regards
    C-Box
  5. C-Box's post in How change height of page footer dynamically or how to add second page footer was marked as the answer   
    Well, the problem  is, that PageFooter Bands are STATIC bands... so they can't stretch itself depending on some content. So this is a normal behaviour and not a bug. Imagine a dynamic pagefooter could cause an infinity loop, when the content causes the pagefooter to increase to a height larger than the page height itself... so you shouldn't use PageFooter Bands for your purpose. Once defined as (e.g.) 100pixel in height, the page footer will use this space at each page and the usage height for other bands is PageHeight -100px.
    You could use some some (dummy) group footer bands and use their footer position type (e.g. stack at bottom). Just put your first "dynamic" frame into GroupFooterBand1 (you should set the PrintWhenExpression then to the whole GroupFooterBand) and the second element/frame into GroupFooterBand2 (or if that element should always appear, then you could use of course the normal static page footer band for the second element as well)
    Should work (as I've done something similiar some years ago in a customer project, but can't access the sources/jrxmls unfortunately) 
    hth + regards
    C-Box
  6. C-Box's post in Generate a set of typical reports based on sql query result was marked as the answer   
    Not sure what you want with a dropdown or anything like this. But as I understand you run a main query that will return several room-ids in a resultset. Let's say room-id 1 to 10.
    So now you want to run a Report that shows each visitors of each single room. So that e.g. 10 different pages will be printed and each of them just shows the visitors of the 10 rooms in our example. So this is what I meant with the MainReport and SubReport logic.
    The main report has no actual design and is just responsible to loop through the rooms. (select * from rooms)  In the detail band of the main report you create a SubReport element and pass the current room-id as a SubReport-Parameter let's call "ParentRoomID" with expression $F{roomID}
    In you SubReport (an own jrxml.design) you now create a ReportParameter with the same name ("ParentRoomID") and in the SubReport-Query you can use this parameter within your where condition (e.g. Select * from visitors where visitors.room_id = $P{ParentRoomID})
    In the SubReport (the jrxml) you now can define the whole layout based on the visitors of the (current) room.
    So this is a typical usage scenario of how to call a report x-times based on a (parent) query
    You also can define different SubReports for different room types or whatever you could imagine and use a PrintWhenExpression or an If.Then.Else expression based on a certain room field to use different layout if needed... so the limit is the sky ;-)
    hth + regards
    C-Box.
     
  7. C-Box's post in How to pass type F or type P parameters to subreports? was marked as the answer   
    You should use a copy of your passed JRBeanCollectionDataSource if you use it multiple times in SubReports. Otherwise the internal pointer to the next record will be forwarded so that the data are just shown once. So you can use the clone() method for that purpose in your SubReport DataSourceExpression, when I remember right. ;-)
    hth + regards
    C-Box
  8. C-Box's post in Can I invert the order of a Y Values in a Line Chart? was marked as the answer   
    Can't you just invert the lable expression itself again, when this is the only problem?!? :-)
    just an idea - not tried.
    Otherwise create a small ChartCustomizer and set the invertion flag to the plot, then you probably won't negate the values before
    ChartPanel.getChart().getXYPlot().getRangeAxis().setInverted(true)
    hth + regards
    C-Box
     
  9. C-Box's post in Page break between two detail bands was marked as the answer   
    But there is an page-break element in your first detail band (at y=120)? As you wrote "you don't want a page break between the bands", why did you placed a break element there?
    Additionally I would NOT advice using StretchType RelativeToTallestObject for both table elements? I can't imagine any wanted effect where both tables should stretch against the biggest one in the second detail!??! Or why did you adjust that?
    hth + regards
    C-Box
  10. C-Box's post in iReport Designer 5.6.0 - subreport not displayed in the main report was marked as the answer   
    As you don't pass any data nor use a query that returns any results inside your subReport this SubReport doesn't iterate through any records. So no detail is rendered at all.
    So I would advice to use the "NoDataSection" in your SubReport for your static text sample and set the ReportProperty "WhenNoDataType" to "No Data Section" in the subreports jrxml.
    Otherwise you could also pass an JREmptyDataSource as SubReport-DataSourceExpression instead the ReportConnection, so that the SubReport will render some dummy contents as well.
    Or you place the static text just into the Title band of your SubReport and use "WhenNoDataType" = "AllSectionsNoDetail" to see whether your SubReport is called at all.
    Or last but not least -  just create a query within the SubReport that will return some records. 
    ;-)
    hth + regards
    C-Box
  11. C-Box's post in Question about display data in groups was marked as the answer   
    Not sure, whether I understood correctly but it seems that you could use a group with (concated) Expression $F{ColA}+$F{ColB} then you but both fields from ColumnA and ColumnB into the groupHeader-Band and the other two fields from ColC and ColD into the detail-Band with a slight indention. For numbering the groups you could just create a simple variable "MyGroupNumber" and add just 1 with calculation time group. (e.g. for variable expression $V{MyGroupNumber} +1)
    just give it  a try or post if I missunderstood the problem
    hth + regards
    C-Box
  12. C-Box's post in Different footer same Group (layout) was marked as the answer   
    Have you already tried to create two groups with the same group-expression instead of one group with two footerbands? At the "outer" group for "TermsAndConditions" you could then set "StackToBottom" or whatever you wan't to appear at the page and the "inner" groupfooter for "SubTotals" is just printing right after the last detail.
    just give it a try - should work.
    Otherwise you could also use a SubReport for your TermsAndConditions and set the Flag "RunToBottom" - should also work.
    Many ways are leading to Rome! :-)
    hth + regards
    C-Box
  13. C-Box's post in Can we call a java function from jrxml file If yes any example to acheive this? was marked as the answer   
    Just create a class like
    package de.cbox.test;import java.lang.*; public class MyTest { public static String getSomeStuffByField(String fieldContent) { return "SomeStuffF filled or modified with your field content: " + fieldContent; }}[/code]create a jar for that class and put that into your classpath.
    From within your jrxml file you could then easily access that method within an expression:
    de.cbox.test.MyTest.getSomeStuffByField($F{YourFieldFromJRXML})[/code]if you are too lazy to write the full package path always you also can add the package to the "imports properties" in your jrxml and then just use the shorter syntax:
    MyTest.getSomeStuffByField($F{YourFieldFromJRXML})[/code]and voilá it will print the result of that static method. 
    hth + regards
    C-Box
  14. C-Box's post in clear site-break between result set rows was marked as the answer   
    Hi Philipp,
    I would use a Group per (primary) ID at your MainReport level and set the "StartOnNewPage" flag. So each "MainReport-Record" would start on a new page.... all SubRecords rendered by the SubReport(s) will consume seval pages, depending of the amount of SubRecords... if they finished, the MainReport will iterate to the next MainRecord and because of the grouping a new (main)page will start.
    hth + regards from Dresden
    C-Box
  15. C-Box's post in Table border missing when content too long was marked as the answer   
    Have you used the TableComponent or just placed simple textfields with borders in Detail-Band and put the static lables in ColumnHeader-Band (so my guess)?
    If second, I would advice using simple vertical lines with StretchType = RelativeToBandHeight instead textfield borders. So you can achieve, that also the other "columns" are visible.Make the textfields in detail also to "transparent" (so not opaque)
    Also the ugly overlapping of your stretching TextField and ColumnHeader in 2. Column would then disappear. 
    hth + regards
    C-Box
  16. C-Box's post in Printing frame repeated as Down Cross was marked as the answer   
    You could use 2 columns (adjust at report level) with horizontal filling for that.
    Works fine for printing labels etc.  but I doubt that a "real" frame element would stretch itself from one column to anonther. 
    Just give it a try. :-)
    hth + regards
    C-Box
  17. C-Box's post in How to print Chinese characters in PDF? was marked as the answer   
    I guess you will have to build a font-extension for your Arial-Unicode font and set the pdf-encoding to IDENTITY-H and not to Cp1250 (what is central european... a bit far away from our chinese friends!??! :-) )
    Also I'd advice not to adjust the pdf-encoding stuff at each single TextElement level but instead on a default-style report level... otherwise the report is heavy to maintain later.
    The font-extension must be within the classpath or your java-application (if you export reports from that and not only from designer)
    just see the JasperReports Docus e.g.: https://community.jaspersoft.com/documentation/tibco-jaspersoft-studio-user-guide/v640/working-font-extensions
    hth + regards
    C-Box
  18. C-Box's post in How i can to convert a Date that is null to String was marked as the answer   
    Just use a simple IfThenElse Expression for your date field (e.g. here without text pattern for a java.util.Date Field, but  instead with a SimpleDateFormat for a plain StringField):
    $F{YourDateField} == null ? "no date found": new SimpleDateFormat("dd.MM.yyyy").format($F{YourDateField})[/code]If you have multiple date fields and you just want to define the static text once, you also could use an own parameter (without prompting) with a default expression for your default static text:
     
    $F{YourDateField} == null ? $P{YourDefaultText4NullDates}: new SimpleDateFormat("dd.MM.yyyy").format($F{YourDateField})[/code]Another way could also be a static scriptlet method within a small java proggi that handles your logic on a central point:
    YourScriptletClass.getDateOrText($F{YourDateField})[/code]so like always: Many ways leading to Rome :-)
    hth + regards
    C-Box
  19. C-Box's post in fix a font in an empty field was marked as the answer   
    Perhaps you could use a non breaking space character ("u00A0") instead of a real empty textfield, that probably will be removed when exporting to word, as it's empty.
    So the defined font, should actually also  be kept in doc(x)-exporter, as the textfield isn't really empty.
    Not tried, but worth to test
    hth + regards
    C-Box
  20. C-Box's post in Error evaluating expression for Integer.valueOf($P{string}) was marked as the answer   
    I would use following as Default Expression for your Integer Parameter:
    $P{s_incident} == null || "".equals($P{s_incident}.trim())? new Integer(0) : Integer.valueOf($P{s_incident})
    hth + regards
    C-Box
  21. C-Box's post in Calculate Sum in table column per page was marked as the answer   
    I guess your detail for the last record is actual started at page 11 and now the enginge recognized that your description is probably StretchWithOverflow=true and that's why the whole content won't fit into the remaining space at page11... so a page-break will be done and the whole detail is transferred to the page 12.
    But the variable for your carry is already evaluated, as the band already started. 
    So this is what I guess! (not verified, but after "some" years of using JasperReports). 
    To prevent this you could either try to set the SplitType of your detail to "PREVENT"....or you could try to create a "dummy group" with an attribute "MinHeightToStartNewPage" > 30px (or an other TrialAndError value)  or you also could use another detail-band for your "splitting" content and just place the "one-line" fields including amount into the first detail.
    If you look into the JasperSoft-Tracker you will find a BugReport some years ago, where I discussed the "Strange Carry Calculation" with Teodord Danciu.... When I remember right, the result of this was a new Splitting type "immediate" .... but I forgot unfortunatly what exactly this is doing. (and it just worked for simple layouts, but not complex SubReports Frames Structures)
    So finally just give it a try ... the last chance would be to correct it in the generated JasperPrint Object by JavaAPI... (this is, what I did finally  ... so I just "marked" the amount fields and calculate it's contents for a Sum per page and "correct" the JRPrintText of the CarryField at the bottom per page -  not nice, but working at many customers since several years)
     
    hth + regards
    C-Box
  22. C-Box's post in Use certain value of a result set was marked as the answer   
    Where do you need your "certain values" exactly? In MainReport as a result from SubReport? Or outside your whole report in your (calling) java application?
    It's not clear for me, what exactly you want to achieve with the result of column B in your third record!??!?!
    If you just want to calculate something at MainReportLevel based on that certain third value in columnB from a SubReport, than you could use a ReturnVariable.
    In your SubReport you could use a simple variable let's call $V{MyColumnBatRecord3}  - with an if-then-expression that "remembers" the value of column B in the 3. record:
    $V{REPORT_COUNT} == 3? $F{fieldColumnB} : $V{MyColumnBatRecord3}
    but as I said, it's not exactly clear for me, what you actually want to achieve.
    hth + regards
    C-Box
  23. C-Box's post in How can I rotate itemLabels of a bar char? was marked as the answer   
    I guess you will create a simple ChartCustomizer for that.
    Just take a look here    https://mdahlman.wordpress.com/2010/08/18/chart-customizers-1/ and also https://mdahlman.wordpress.com/2011/04/17/chart-customizers-2/  
    where MDahlman posted some good snippets/samples for "inspiration"  :-)
     
    just googled it 4u:  https://stackoverflow.com/questions/15024082/how-can-i-rotate-itemlabels-above-bars-in-bar-chart-of-a-jasper-report   could be a solution. ;-)
    hth + regards
    C-Box
  24. C-Box's post in Embedded jasperreports java desktop aplication was marked as the answer   
    IMHO you won't need a full JDK installed at a client just to use the jasperreports built-in viewer. A JRE should be enough, as our customers also just use a runtime.
    So probably a library is missing, so there should be thrown an exception - please post the stacktrace to identify the problem
    regards
    C-Box
  25. C-Box's post in How to print a list in horizontal wise ? was marked as the answer   
    Have you already tried to define 3 columns at your report and place the field A and B into the first column-detail band?
    If you already set the PrintOrder to horizontal, than your output should be
    COL 1 _____ COL2 _____ COL3
    1 to 7   _____ 2 to 8 _____ 3 to 9
    4 to 10  _____ 5 to 11 _____6 to 12
    Don't use ListElement --- if your data came from a SubDataSet, than use a SubReport for it.... In my experiences, the ListElement is just useable for very simple constructs. I refactored many customer reports where initially a listelement was used but later one some sums or breaking logic should be integrated what finally always ended in using SubReports instead of ListElements.
    hth + regards 
    C-Box
×
×
  • Create New...