sciuridae0603 Posted August 12, 2019 Share Posted August 12, 2019 Hi there ,I need to load data from JSON array (no key , only index) to table,Is there has a way to create table content like this JSON format?[["1","2","3","4","5"],["6","7","8","9","10"]][/code]I want it display like this or this thanks. Link to comment Share on other sites More sharing options...
Solution narcism Posted August 13, 2019 Solution Share Posted August 13, 2019 The horizontal display can be achieved like this with lists:<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.9.0.final using JasperReports Library version 6.9.0-cb8f9004be492ccc537180b49c026951f4220bf3 --><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Report_v1" pageWidth="595" pageHeight="842" columnWidth="90" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="86523aef-3262-499e-ae57-66e5dabd4218"> <subDataset name="ListDataSet" uuid="fb812d2a-cb63-473c-b7d3-149977476dd0"> <field name="val" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="[0]"/> </field> </subDataset> <queryString language="jsonql"> <![CDATA[]]> </queryString> <background> <band splitType="Stretch"/> </background> <title> <band height="79" splitType="Stretch"> <staticText> <reportElement x="180" y="20" width="200" height="30" uuid="4014c1c1-e6a1-4d22-a50f-6cedeac55ead"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="14"/> </textElement> <text><![CDATA[Horizontal Display]]></text> </staticText> </band> </title> <pageHeader> <band height="30" splitType="Stretch"/> </pageHeader> <columnHeader> <band height="30"> <staticText> <reportElement mode="Opaque" x="360" y="0" width="90" height="30" backcolor="#9AF5E1" uuid="ec8aaa95-0f7b-42cf-b858-eca1c1f6938d"/> <text><![CDATA[Remark]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="180" y="0" width="90" height="30" backcolor="#9AF5E1" uuid="645a5553-e3bd-4949-92a9-a56ab0f4f31e"/> <text><![CDATA[Fax]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="0" y="0" width="90" height="30" backcolor="#9AF5E1" uuid="82279926-fcc9-4111-a8ba-d215eddc5b18"/> <text><![CDATA[Name]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="90" y="0" width="90" height="30" backcolor="#9AF5E1" uuid="243d1437-6676-49de-bb75-1f3341716646"/> <text><![CDATA[Tel]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="270" y="0" width="90" height="30" backcolor="#9AF5E1" uuid="50b884d0-5d0f-40e7-ab35-e6f26f870ca6"/> <text><![CDATA[Address]]></text> </staticText> </band> </columnHeader> <detail> <band height="30" splitType="Stretch"> <componentElement> <reportElement x="0" y="0" width="450" height="30" uuid="887dc258-2eac-4492-ae69-f9b2ffd1faee"> <property name="com.jaspersoft.studio.unit.CONTENTS.width" value="px"/> </reportElement> <jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Horizontal"> <datasetRun subDataset="ListDataSet" uuid="1316cfd7-fe59-440f-a155-501914c00056"> <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonQLDataSource)($P{REPORT_DATA_SOURCE})).subDataSource()]]></dataSourceExpression> </datasetRun> <jr:listContents height="30" width="90"> <textField> <reportElement x="0" y="0" width="90" height="30" uuid="4ee2d6b3-c681-433f-a170-4bb31697de58"/> <textFieldExpression><![CDATA[$F{val}]]></textFieldExpression> </textField> </jr:listContents> </jr:list> </componentElement> </band> </detail> <summary> <band height="42" splitType="Stretch"/> </summary></jasperReport>The preview:The vertical display can be done this way, with nested lists:<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.9.0.final using JasperReports Library version 6.9.0-cb8f9004be492ccc537180b49c026951f4220bf3 --><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Report_v2" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="90" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="86523aef-3262-499e-ae57-66e5dabd4218"> <subDataset name="HorizontalListDataSet" uuid="fb812d2a-cb63-473c-b7d3-149977476dd0"/> <subDataset name="VerticalListDataSet" uuid="86686d59-46df-43f1-b2bf-82998d8569be"> <field name="val" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="[0]"/> </field> </subDataset> <queryString language="jsonql"> <![CDATA[]]> </queryString> <title> <band height="79" splitType="Stretch"> <staticText> <reportElement x="180" y="20" width="200" height="30" uuid="4014c1c1-e6a1-4d22-a50f-6cedeac55ead"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="14"/> </textElement> <text><![CDATA[Vertical Display]]></text> </staticText> </band> </title> <pageHeader> <band height="30" splitType="Stretch"> <staticText> <reportElement mode="Opaque" x="90" y="0" width="90" height="30" backcolor="#9AF5E1" uuid="243d1437-6676-49de-bb75-1f3341716646"/> <text><![CDATA[Tel]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="0" y="0" width="90" height="30" backcolor="#9AF5E1" uuid="82279926-fcc9-4111-a8ba-d215eddc5b18"> <property name="com.jaspersoft.studio.unit.leftIndent" value="px"/> <property name="com.jaspersoft.studio.unit.spacingBefore" value="pixel"/> </reportElement> <textElement> <paragraph leftIndent="0"/> </textElement> <text><![CDATA[Name]]></text> </staticText> </band> </pageHeader> <summary> <band height="50"> <componentElement> <reportElement x="0" y="0" width="180" height="30" uuid="887dc258-2eac-4492-ae69-f9b2ffd1faee"> <property name="com.jaspersoft.studio.unit.CONTENTS.width" value="px"/> </reportElement> <jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Horizontal"> <datasetRun subDataset="HorizontalListDataSet" uuid="1316cfd7-fe59-440f-a155-501914c00056"> <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonQLDataSource)($P{REPORT_DATA_SOURCE})).subDataSource("^")]]></dataSourceExpression> </datasetRun> <jr:listContents height="30" width="90"> <componentElement> <reportElement x="0" y="0" width="90" height="30" uuid="3ba51777-567a-495e-b631-ac03510fdbb0"/> <jr:list printOrder="Vertical"> <datasetRun subDataset="VerticalListDataSet" uuid="c4c4534b-2081-4903-84f2-42621c022a3c"> <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonQLDataSource)($P{REPORT_DATA_SOURCE})).subDataSource()]]></dataSourceExpression> </datasetRun> <jr:listContents height="30" width="90"> <textField> <reportElement x="0" y="0" width="90" height="30" uuid="4aab6768-2a75-4d88-995a-45a9af3732d1"/> <textFieldExpression><![CDATA[$F{val}]]></textFieldExpression> </textField> </jr:listContents> </jr:list> </componentElement> </jr:listContents> </jr:list> </componentElement> </band> </summary></jasperReport>The preview: Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now