Jump to content
We've recently updated our Privacy Statement, available here ×

akovach

Members
  • Posts

    30
  • Joined

  • Last visited

 Content Type 

Profiles

Forum

Events

Featured Visualizations

Knowledge Base

Documentation (PDF Downloads)

Blog

Documentation (Test Area)

Documentation

Dr. Jaspersoft Webinar Series

Downloads

Everything posted by akovach

  1. Issue DescriptionUser wants to create a subreport with data from main report SQL query which is in JSON format. ResolutionTo create such report we would need to create to reports: main report (MainReport.jrxml) and subreport(SubReport.jrxml). Main have ordinary SQL Query which gets data from DB Table. This query can be represented by the following statement: SELECT "json_text" , "id" FROM (VALUES ('[{ ''dateFrom'': ''01.12.2016'', ''dateTo'': ''01.12.2016'', ''someOptionalNumber'': 12 },{ ''dateFrom'': ''01.12.2016'', ''dateTo'': ''01.12.2016'' }, { ''dateFrom'': ''01.12.2016'', ''dateTo'': ''01.12.2016'', ''someOptionalNumber'': 11 }]', 1) ) s("json_text" , "id") The structure of main report is simple: a Title and a Subreport element in Summary band Subreport element should contain several parameters: 'JSON_INPUT_STREAM' and 'net.sf.jasperreports.json.date.pattern'. 'JSON_INPUT_STREAM' is needed to process JSON String from the main report field and pass it to subreport. 'net.sf.jasperreports.json.date.pattern' is used as a pattern for dates in subreport. The code for subreport element: <subreport> <reportElement x="-1" y="0" width="545" height="320" uuid="b11b1e89-b446-44a6-aa9e-c12fdba2d428"/> <subreportParameter name="JSON_INPUT_STREAM"> <subreportParameterExpression><![CDATA[new ByteArrayInputStream($F{json_text}.getBytes("UTF-8"))]]></subreportParameterExpression> </subreportParameter> <subreportParameter name="net.sf.jasperreports.json.date.pattern"> <subreportParameterExpression><![CDATA["d.m.y"]]></subreportParameterExpression> </subreportParameter> <subreportExpression><![CDATA["Blank_A4.jasper"]]></subreportExpression> </subreport>Subreport should have query language 'JSON': <queryString language="json"> <![CDATA[]]> </queryString> Please make sure, that subreport contains all actual fields, which are in JSON String (in this case: "dateFrom", "dateTo", "someOptionalNumber"): Now we can publish main report to JasperReports Server to check the result. As you can see, JSON String was passed to subreport and parsed correctly by JSON executer: mainreport.jrxml subreport.jrxml
  2. Hello, Do you mean you want to get day part from date? If so, you can use the following expression: new SimpleDateFormat("dd").format($F{YourDateField}) Cheers,
  3. Hello, xAxis.tickInterval property should help you. Refer to the following link for details: TickInterval on Axis Cheers,
  4. Issue DescriptionUser wants to have different currency symbol for each Organization. User can format text fields in .jrxml report with different patterns. However, these patterns does not allow to use different currency symbols ResolutionThere is a way to maintain different currency symbol using Org attributes to create a pattern for currency text field. First step would be creating two Org attributes 'language' and 'region'. Go to Manage > Organizations, choose your organization > edit, add two attributes with values 'sv' and 'SE' accordingly (These values represent Sweden Locale). A report, i created for test has one text field and static text field: Second step is a creation of parameters for pattern. For our pattern we would need three paramters (Type String): LoggedInTenantAttribute_languageLoggedInTenantAttribute_regionCurrencyPatternParameters 'LoggedInTenantAttribute_language' and 'LoggedInTenantAttribute_region' are built-in attributes parameters in TIBCO JasperReports® Server so we do not need expression for them. For parameter CurrencyPattern insert the following expression: ((DecimalFormat)(NumberFormat.getCurrencyInstance(new Locale($P{LoggedInTenantAttribute_language}, $P{LoggedInTenantAttribute_region})))).toPattern().replace("u00a4", DecimalFormatSymbols.getInstance(new Locale($P{LoggedInTenantAttribute_language}, $P{LoggedInTenantAttribute_region})).getCurrencySymbol()) Then add a pattern for your text field. Go to text field properties > Text Field tab > Pattern Expression and choose parameter CurrencyPattern. Lets test this report. Publish report from TIBCO Jaspersoft® Studio to JasperReports Server, login with user which belongs to your organization and run the report. As a result you get a text field with formatted currency sign (Sweden kr in our case) ReferencesBuilt-In Parameter Attributes Java SE 8 Supported Locales Display Org Name in Report akovach case ref. 01583717 currencytest.jrxml
×
×
  • Create New...