[英]net.sf.jasperreports.engine.JRException: Invalid page index range : 0 - -1 of 0
When I try printing the Jasper report it gets me the message: "net.sf.jasperreports.engine.JRException: Invalid page index range : 0 - -1 of 0".当我尝试打印 Jasper 报告时,它收到消息:“net.sf.jasperreports.engine.JRException:无效的页面索引范围:0 - -1 of 0”。
Code:代码:
try {
JasperPrint impressao = JasperFillManager.fillReport(getClass().getClassLoader().getResourceAsStream("example.jasper"), parametros);
JasperExportManager.exportReportToPdf(impressao);
JasperPrintManager.printReport(impressao, true);
} catch (JRException e) {
e.printStackTrace();
}
Report:报告:
<?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="base-estadual" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="9cbb7afc-abb5-4207-a29b-a0c7adde7df6">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="250"/>
<import value="com.myproject.ed.*"/>
<parameter name="PATH_IMAGENS" class="java.lang.String"/>
<queryString>
<![CDATA[]]>
</queryString>
<background>
<band splitType="Stretch"/>
</background>
<pageHeader>
<band height="63">
<textField evaluationTime="Report">
<reportElement x="515" y="16" width="40" height="20" uuid="3892152b-6880-41da-bbc7-7bf79588061d"/>
<textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]>/textFieldExpression>
</textField>
</band>
</pageHeader>
Could someone help me to figure out why is it happening?有人可以帮我弄清楚为什么会这样吗?
JasperFillManager likes to get a data source, even when you don't really have any. JasperFillManager喜欢获取数据源,即使你真的没有。 You could try adding an empty data source as a third parameter to JasperFillManager.fillReport:
您可以尝试将空数据源作为第三个参数添加到JasperFillManager.fillReport:
JasperPrint impressao = JasperFillManager.fillReport(getClass().getClassLoader().getResourceAsStream("example.jasper"), parametros, new JREmptyDataSource());
Check whether the parameters which you are passing to the JasperFillManager.fillReport()
is not null or empty.检查您传递给
JasperFillManager.fillReport()
的参数是否不为空或不为空。 If it is empty or null then you will receive this same error.如果它为空或 null,那么您将收到同样的错误。
JasperPrint impressao = JasperFillManager.fillReport(getClass().getClassLoader().getResourceAsStream("example.jasper"), parametros);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.