A busca está sendo feita, não exibe erro no console. Gera o relatório, mas em branco. O que pode estar errado ou faltando ?
List<TratFpOperacaoDTO> listaDto = tratFpService.exportarPdfExcel(corridas);
Map<String, Object> params = new HashMap<String, Object>();
String caminhoCompleto = "/processo/web/rest/relatorios/";
String nome = "folhaCorridaFornoPanela";
InputStream jasperStream = this.getClass().getResourceAsStream(caminhoCompleto + nome + ".jasper");
JasperReport jasperReport = (JasperReport) loadObject(jasperStream);
JRBeanCollectionDataSource dataSource = new JRBeanCollectionDataSource(listaDto);
JasperPrint jasperPrint = fillReport(jasperReport, params, dataSource);
response.setContentType("application/x-pdf");
response.setHeader("Content-disposition", "inline; filename=" + nome + "." + PDF);
byte[] b = JasperExportManager.exportReportToPdf(jasperPrint);
OutputStream outStream = response.getOutputStream();
outStream.write(b);
exportReportToPdfStream(jasperPrint, outStream);
Relatório jasper.
<?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="folhaCorridaFornoPanela" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="ireport.zoom" value="1.1000000000000003"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="26" splitType="Stretch">
<staticText>
<reportElement x="5" y="0" width="269" height="26"/>
<textElement verticalAlignment="Middle">
<font fontName="Arial" size="12" isBold="true"/>
</textElement>
<text><![CDATA[Folha de Corrida Forno Panela]]></text>
</staticText>
</band>
</title>
<columnHeader>
<band height="147" splitType="Stretch">
<frame>
<reportElement x="0" y="0" width="801" height="95"/>
<staticText>
<reportElement x="0" y="0" width="56" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10" isBold="true"/>
</textElement>
<text><![CDATA[Corrida]]></text>
</staticText>
<staticText>
<reportElement mode="Transparent" x="735" y="0" width="66" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false"/>
</textElement>
<text><![CDATA[Aço Liq.]]></text>
</staticText>
<staticText>
<reportElement x="550" y="0" width="43" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10" isBold="true"/>
</textElement>
<text><![CDATA[Lib. LD.]]></text>
</staticText>
<staticText>
<reportElement x="284" y="0" width="66" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10" isBold="true"/>
</textElement>
<text><![CDATA[Aço Exec.]]></text>
</staticText>
<staticText>
<reportElement x="593" y="0" width="66" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10" isBold="true"/>
</textElement>
<text><![CDATA[Temp. Lib.]]></text>
</staticText>
<staticText>
<reportElement x="171" y="0" width="47" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10" isBold="true"/>
</textElement>
<text><![CDATA[Turno]]></text>
</staticText>
<staticText>
<reportElement x="416" y="0" width="68" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10" isBold="true"/>
</textElement>
<text><![CDATA[Vida Pan.]]></text>
</staticText>
<staticText>
<reportElement x="56" y="0" width="64" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10" isBold="true"/>
</textElement>
<text><![CDATA[Data]]></text>
</staticText>
<staticText>
<reportElement x="120" y="0" width="51" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10" isBold="true"/>
</textElement>
<text><![CDATA[Turma]]></text>
</staticText>
<staticText>
<reportElement x="484" y="0" width="66" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10" isBold="true"/>
</textElement>
<text><![CDATA[Diam Pan.]]></text>
</staticText>
<staticText>
<reportElement x="350" y="0" width="66" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10" isBold="true"/>
</textElement>
<text><![CDATA[Nº Pan.]]></text>
</staticText>
<staticText>
<reportElement mode="Transparent" x="659" y="0" width="76" height="20"/>
<box>
<pen lineWidth="1.0"/>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10" isBold="true"/>
</textElement>
<text><![CDATA[Cons. (KW/H)]]></text>
</staticText>
<staticText>
<reportElement x="218" y="0" width="66" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10" isBold="true"/>
</textElement>
<text><![CDATA[Aço Prog.]]></text>
</staticText>
</frame>
</band>
</columnHeader>
<pageFooter>
<band height="21" splitType="Stretch">
<textField pattern="EEEEE, dd/MM/yyyy - HH:mm">
<reportElement x="0" y="1" width="426" height="20"/>
<textElement verticalAlignment="Middle">
<font fontName="Arial"/>
</textElement>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
<textField>
<reportElement x="722" y="1" width="80" height="20"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="Arial"/>
</textElement>
<textFieldExpression><![CDATA["Página "+$V{PAGE_NUMBER}+" de " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<line>
<reportElement x="0" y="0" width="801" height="1"/>
</line>
</band>
</pageFooter>
</jasperReport>
É obrigado a ter ?
Estou fazendo somente testes.
Para continuar depois
dlemos
Outubro 29, 2019, 1:49pm
#4
Na propiedade do relatório, “When No Data Type” selecione a opção “All Sections No Detail”.
Mesmo assim não funcionou.
dlemos
Outubro 29, 2019, 2:39pm
#6
Coloca um try catch block, no código que vc usa para gerar, e verifica se não esta lançando nenhuma execption na geração.
Código complet, já tem. Não lança exceção nenhuma.
try {
List<TratFpOperacaoDTO> listaDto = tratFpService.exportarPdfExcel(corridas);
Map<String, Object> params = new HashMap<String, Object>();
String caminhoCompleto = "/processo/web/rest/relatorios/";
String nome = "folhaCorridaFornoPanela";
InputStream jasperStream = this.getClass().getResourceAsStream(caminhoCompleto + nome + JASPER);
JasperReport jasperReport = (JasperReport) loadObject(jasperStream);
JRBeanCollectionDataSource dataSource = new JRBeanCollectionDataSource(listaDto);
JasperPrint jasperPrint = fillReport(jasperReport, params, dataSource);
response.setContentType(APPLICATION_PDF);
response.setHeader(CONTENT_DISPOSITION, INLINE_FILENAME + nome + PONTO + PDF);
byte[] b = JasperExportManager.exportReportToPdf(jasperPrint);
OutputStream outStream = response.getOutputStream();
outStream.write(b);
exportReportToPdfStream(jasperPrint, outStream);
} catch (FolhaCorridaFornoPanelaException e) {
e.printStackTrace();
} catch (JRException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
guilhermebhte:
É obrigado a ter ?
Cara, até onde eu lembro, se não tem details, não exibe nada mesmo.
Inclui e não funcionou
Altero o Ireport, Compilo. Paro servidor e testo. Não funciona só fica gera em branco. Será que não estou esquecendo algo no retorno ?
byte[] b = JasperExportManager.exportReportToPdf(jasperPrint); , como vejo o que está aqui, pois entendo que o relatório gerado é este, ou estou enganado ?
Estou trabalhando com REST
<?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="folhaCorridaFornoPanela" pageWidth="842" pageHeight="595" orientation="Landscape" whenNoDataType="NoDataSection" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="ireport.zoom" value="1.1000000000000003"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="26" splitType="Stretch">
<staticText>
<reportElement x="5" y="0" width="269" height="26"/>
<textElement verticalAlignment="Middle">
<font fontName="Arial" size="12" isBold="true"/>
</textElement>
<text><![CDATA[Folha de Corrida Forno Panela]]></text>
</staticText>
</band>
</title>
<columnHeader>
<band height="147" splitType="Stretch">
<frame>
<reportElement x="0" y="0" width="801" height="95"/>
<staticText>
<reportElement x="0" y="0" width="56" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10" isBold="true"/>
</textElement>
<text><![CDATA[Corrida]]></text>
</staticText>
<staticText>
<reportElement mode="Transparent" x="735" y="0" width="66" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false"/>
</textElement>
<text><![CDATA[Aço Liq.]]></text>
</staticText>
<staticText>
<reportElement x="550" y="0" width="43" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10" isBold="true"/>
</textElement>
<text><![CDATA[Lib. LD.]]></text>
</staticText>
<staticText>
<reportElement x="284" y="0" width="66" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10" isBold="true"/>
</textElement>
<text><![CDATA[Aço Exec.]]></text>
</staticText>
<staticText>
<reportElement x="593" y="0" width="66" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10" isBold="true"/>
</textElement>
<text><![CDATA[Temp. Lib.]]></text>
</staticText>
<staticText>
<reportElement x="171" y="0" width="47" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10" isBold="true"/>
</textElement>
<text><![CDATA[Turno]]></text>
</staticText>
<staticText>
<reportElement x="416" y="0" width="68" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10" isBold="true"/>
</textElement>
<text><![CDATA[Vida Pan.]]></text>
</staticText>
<staticText>
<reportElement x="56" y="0" width="64" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10" isBold="true"/>
</textElement>
<text><![CDATA[Data]]></text>
</staticText>
<staticText>
<reportElement x="120" y="0" width="51" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10" isBold="true"/>
</textElement>
<text><![CDATA[Turma]]></text>
</staticText>
<staticText>
<reportElement x="484" y="0" width="66" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10" isBold="true"/>
</textElement>
<text><![CDATA[Diam Pan.]]></text>
</staticText>
<staticText>
<reportElement x="350" y="0" width="66" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10" isBold="true"/>
</textElement>
<text><![CDATA[Nº Pan.]]></text>
</staticText>
<staticText>
<reportElement mode="Transparent" x="659" y="0" width="76" height="20"/>
<box>
<pen lineWidth="1.0"/>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10" isBold="true"/>
</textElement>
<text><![CDATA[Cons. (KW/H)]]></text>
</staticText>
<staticText>
<reportElement x="218" y="0" width="66" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10" isBold="true"/>
</textElement>
<text><![CDATA[Aço Prog.]]></text>
</staticText>
</frame>
</band>
</columnHeader>
<detail>
<band height="50">
<staticText>
<reportElement x="5" y="17" width="56" height="20"/>
<box>
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10" isBold="true"/>
</textElement>
<text><![CDATA[Corrida]]></text>
</staticText>
</band>
</detail>
<pageFooter>
<band height="21" splitType="Stretch">
<textField pattern="EEEEE, dd/MM/yyyy - HH:mm">
<reportElement x="0" y="1" width="426" height="20"/>
<textElement verticalAlignment="Middle">
<font fontName="Arial"/>
</textElement>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
<textField>
<reportElement x="722" y="1" width="80" height="20"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="Arial"/>
</textElement>
<textFieldExpression><![CDATA["Página "+$V{PAGE_NUMBER}+" de " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<line>
<reportElement x="0" y="0" width="801" height="1"/>
</line>
</band>
</pageFooter>
</jasperReport>
Está usando ireport ou jasperreports para gerar o arquivo?
Pelo que entendi, é um relatório com dados definidos, certo?
Por que não coloca toda a estrutura na banda detail (que é o correto)?
Então, o relatório tem um por n, isto é, como se fosse imprimir o estado e suas cidades, depois o estado e suas cidades.
Então eu pensei o estado sendo impressso na band Column Headder e os municipios no detail .
Entende ?
Sim, mas, como você não colocou um, $F{cidade} em nenhum lugar na detail, fica meio complicado.
É porque eu não fiz ainda.
Vou fazer este teste então.
Funcionou, quando passei paremetro.
Agora tenho que passar este classe.
import java.util.List;
public class ListaFornoCorridaFornoPanelaDTO {
private List<TratFpDTO> corridas;
private List<OperacaoFpCadOperacaoDTO> operacoes;
private String observacao;
public List<TratFpDTO> getCorridas() {
return corridas;
}
public void setCorridas(List<TratFpDTO> corridas) {
this.corridas = corridas;
}
public List<OperacaoFpCadOperacaoDTO> getOperacoes() {
return operacoes;
}
public void setOperacoes(List<OperacaoFpCadOperacaoDTO> operacoes) {
this.operacoes = operacoes;
}
public String getObservacao() {
return observacao;
}
public void setObservacao(String observacao) {
this.observacao = observacao;
}
}
Como fazer para importar esta classe para dentro do Ireport ?
Listas e iReport não são uma boa combinação.
O ideal seria você fazer uma classe em que cada registro fosse um elemento específico, uma linha.
No java cada regtistro é um ListaFornoCorridaFornoPanelaDTO.
Mas como disse.
Eu vou ter varias corridas, dentro de uma corrida eu vou ter varias operações e uma observação.
Um relatório, de alguma forma, é como uma tabela num banco de dados. Ou seja, colunas e linhas.
Existem, obviamente, outros tipos de relatórios, mas, são muito menos empregados.
Por isso eu estou te falando que o ideal seria repensar a solução para que você esperasse algo como:
$F{nome} | $F{telefone} | $F{endereco}
E tenha uma lista só de objetos de uma classe como esta
public class DadosRelatorio {
private String nome;
private String telefone;
private String endereco;
//getters e setters omitidos
}
De modo geral, uma lista dentro de um objeto demanda sub reports. E isso não é bom. Funciona? Sim. Mas é uma complexidade que pode não ser adequada.
1 curtida
Entendi, vou fazer aqui e falo o resultado aqui.