Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I like to share my learning of using styles in Jasper reports, which I think quite useful for report designers like me, from a book named JasperReport Development cookbook by Bilal Siddiqui. I like this book and found demonstrating styles in a variety of manner like:</p> <ul> <li><p><strong>Creating a reusable style</strong><br/> Simply select “Style” while creating a new report and define style for text, line and rectangles. The style file will be stored as .jrtx file.</p></li> <li><p>Import reusable style it in your report<br/> There are three chunk of information when importing styles in your report. Step1. Name and location of style template<br/> </p></li> </ul> <blockquote> <pre><code>&lt;template&gt;&lt;![CDATA["C:\\ BigBoldRedTemplate.jrtx"]]&gt;&lt;/template&gt; </code></pre> </blockquote> <p>Step2. Each time you apply style to your report elements using the style template, a <code>&lt;reportElement&gt;</code> tag is created as shown below:</p> <pre><code>//style applied to a rectangle &lt;rectangle radius="10"&gt; &lt;reportElement style="BigBoldRed" mode="Transparent" x="0" y="0" width="555" height="44"/&gt; &lt;/rectangle&gt; //style applied to a the text field &lt;staticText&gt; &lt;reportElement style="BigBoldRed" x="0" y="0" width="555" height="66"/&gt; &lt;textElement textAlignment="Center" verticalAlignment="Middle"/&gt; &lt;text&gt;&lt;![CDATA[Monthly Customer Invoices]]&gt;&lt;/text&gt; &lt;/staticText&gt; </code></pre> <ul> <li><strong>Mixing the internal and reusable styles in report</strong><br/></li> <li><strong>Using the power of HTML to style your report</strong> <br/> For example, your text field has following expression which includes HTML tags (i.e. <code>&lt;li&gt;</code>) and you want the HTML tags to work in your report design:</li> </ul> <blockquote> <pre><code>"&lt;li&gt;"+"Invoice # "+$F{InvoiceID}+", "+ </code></pre> <p>$F{CustomerName}+" purchased "+$F{ProductName}+" in "+$F{InvoicePeriod}+" (Invoice value: \$ "+$F{InvoiceValue}+")"+"</li></p> </blockquote> <p>Solution is simple, just set “Markup” property of the text field to “Styled” and that it.</p> <p>I have taken permission from the author to copy code chunk from his JasperReports cookbook in this post.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload