Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何指定JSON文件作为JasperStarter的数据源?_Java_Json_Jasper Reports_Jasperstarter - Fatal编程技术网

Java 如何指定JSON文件作为JasperStarter的数据源?

Java 如何指定JSON文件作为JasperStarter的数据源?,java,json,jasper-reports,jasperstarter,Java,Json,Jasper Reports,Jasperstarter,我正在从命令行使用jasperster运行Jasper报告,使用process(pr)命令。JasperStarter的版本是3.1.0,当键入JasperStarter--help时,显示有一个--json查询选项。我能找到的唯一文档是: 它适用于3.0.0(并且没有--json查询选项) 我需要提供一个JSON文件作为报告的数据源,但看不到这是如何实现的。我尝试了以下方法,但没有成功: jasperstarter.exe pr -f pdf -o MyReportName MyReport

我正在从命令行使用jasperster运行Jasper报告,使用process(
pr
)命令。JasperStarter的版本是3.1.0,当键入
JasperStarter--help
时,显示有一个
--json查询
选项。我能找到的唯一文档是:

它适用于3.0.0(并且没有
--json查询
选项)

我需要提供一个JSON文件作为报告的数据源,但看不到这是如何实现的。我尝试了以下方法,但没有成功:

jasperstarter.exe pr -f pdf -o MyReportName MyReportTemplate --json-query MyJson.json

我如何告诉JasperStarter使用JSON文件作为数据源?

这就是我使用JasperStarter 3.1.0二进制文件的方法:

jasperster.exe pr-t json--json查询“Northwind.Customers”--数据文件Northwind.json-f pdf-o报告输出JsonCustomersReport.jrxml

我已将
JsonCustomersReport.jrxml
northwind.json
放在运行命令的同一文件夹中

JsonCustomersReport.jrxml
是中的一个修改版本(我已经删除了指定JSON文件、查询字符串和子报表声明的属性):


northwind.json
也是来自的。

我认为您必须使用--data文件MyJson.json作为数据源文件访问json。
<?xml version="1.0" encoding="UTF-8"?>
<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="JsonCustomersReport" pageWidth="595" pageHeight="842" columnWidth="515" leftMargin="40" rightMargin="40" topMargin="50" bottomMargin="50" uuid="bbe115b5-a5a0-4b39-9b73-7092dc59ab6d">
    <style name="Sans_Normal" isDefault="true" fontName="DejaVu Sans" fontSize="12" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false"/>
    <style name="Sans_Bold" fontName="DejaVu Sans" fontSize="12" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false"/>
    <style name="Sans_Italic" fontName="DejaVu Sans" fontSize="12" isBold="false" isItalic="true" isUnderline="false" isStrikeThrough="false"/>
    <field name="CustomerID" class="java.lang.String">
        <property name="net.sf.jasperreports.json.field.expression" value="CustomerID"/>
    </field>
    <field name="CompanyName" class="java.lang.String">
        <property name="net.sf.jasperreports.json.field.expression" value="CompanyName"/>
    </field>
    <title>
        <band height="50">
            <line>
                <reportElement x="0" y="0" width="515" height="1" uuid="fc148b4e-50df-4a12-aa14-8505a4cfa6e1"/>
            </line>
            <staticText>
                <reportElement style="Sans_Normal" x="0" y="10" width="515" height="30" uuid="5bf7651c-cd6b-4eaf-b65a-1413d60faab0"/>
                <textElement textAlignment="Center">
                    <font size="22"/>
                </textElement>
                <text><![CDATA[Customer Orders Report]]></text>
            </staticText>
        </band>
    </title>
    <pageHeader>
        <band height="21">
            <staticText>
                <reportElement style="Sans_Bold" mode="Opaque" x="0" y="5" width="515" height="15" forecolor="#FFFFFF" backcolor="#333333" uuid="da0f1cad-f552-424b-bf19-b41cabbfa4ac"/>
                <text><![CDATA[Customer Order List]]></text>
            </staticText>
        </band>
    </pageHeader>
    <detail>
        <band height="50">
            <textField>
                <reportElement style="Sans_Bold" x="5" y="5" width="100" height="15" isPrintWhenDetailOverflows="true" uuid="0aaeed6e-7ba1-4ab9-be59-d6ca702995fc"/>
                <textFieldExpression><![CDATA[$F{CustomerID}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement style="Sans_Bold" isPrintRepeatedValues="false" x="404" y="5" width="100" height="15" isPrintWhenDetailOverflows="true" uuid="68e08f51-8c24-4c85-95f3-616e40c8ddab"/>
                <text><![CDATA[(continued)]]></text>
            </staticText>
            <line>
                <reportElement x="0" y="20" width="515" height="1" isPrintWhenDetailOverflows="true" uuid="6d76c22c-329f-4e77-a886-8580d3cb6bc1"/>
            </line>
            <textField>
                <reportElement style="Sans_Bold" x="109" y="5" width="291" height="15" isPrintWhenDetailOverflows="true" uuid="9a4a0a5d-4b75-4d2b-a647-aa495101df48"/>
                <textFieldExpression><![CDATA[$F{CompanyName}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <pageFooter>
        <band height="40">
            <line>
                <reportElement x="0" y="10" width="515" height="1" uuid="1371178a-a590-4616-affe-a4e1a24bcc84"/>
            </line>
            <textField>
                <reportElement x="200" y="20" width="80" height="15" uuid="3eb302d8-0855-4f82-a666-3c9628dce372"/>
                <textElement textAlignment="Right"/>
                <textFieldExpression><![CDATA["Page " + String.valueOf($V{PAGE_NUMBER}) + " of"]]></textFieldExpression>
            </textField>
            <textField evaluationTime="Report">
                <reportElement x="280" y="20" width="75" height="15" uuid="86f46fca-dbcb-4a60-b2f7-f8da6a4224f7"/>
                <textFieldExpression><![CDATA[" " + String.valueOf($V{PAGE_NUMBER})]]></textFieldExpression>
            </textField>
        </band>
    </pageFooter>
</jasperReport>