Spring boot - Jasper Report Gerando em Branco

2 respostas
jasperspringspring-bootjavaprogramação
G

Olá, pessoal.

Então quando eu tento gerar o pdf via endpoint gera um o relatorio em branco alguem poderia me ajudar ?

// Classe Repository

@Repository
@EnableJpaRepositories
public interface ConsultaNfseRepository extends JpaRepository<ConsultaNfse, Integer> {

@Query("select u from ConsultaNfse u where u.codigoVerificacao = ?1")
List<ConsultaNfse> findByCodigoVerificacao(String codigoVerificacao);

}

//Service

public String exportPdfRelatorioConsultaNfseCuritiba(String reportFormat, String codigoVerificacao)
throws FileNotFoundException, JRException {

List<ConsultaNfse> employees = consultanfserepository.findByCodigoVerificacao(codigoVerificacao);
    //load file and compile it
    File file = ResourceUtils.getFile("classpath:relatorioprefeituranfsecuritiba.jrxml");
    JasperReport jasperReport = JasperCompileManager.compileReport(file.getAbsolutePath());
    JRBeanCollectionDataSource dataSource = new JRBeanCollectionDataSource(employees);
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("createdBy", "Java Techie");
    JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, dataSource);
    if (reportFormat.equalsIgnoreCase("html")) {
        JasperExportManager.exportReportToHtmlFile(jasperPrint, "C:\\stream" + "\\employees.html");
    }
    if (reportFormat.equalsIgnoreCase("pdf")) {
        JasperExportManager.exportReportToPdfFile(jasperPrint, "C:\\stream" + "\\employees.pdf");
    }

    return "report generated in path : ";
}

Classe Resources

@RequestMapping(value="/exportPdf/{reportFormat}/{codigoVerificacao}", method=RequestMethod.GET)
public String generateReport(@PathVariable String reportFormat,String codigoVerificacao) throws FileNotFoundException, JRException {
		return consultanfseservice.exportPdfRelatorioConsultaNfseCuritiba(reportFormat,codigoVerificacao);
}

2 Respostas

L

Está ocorrendo algum erro na execução?

G


image

quando clico para gerar uma nota fiscal aparece que gerou porem ele não pega meu layout

Criado 18 de fevereiro de 2022
Ultima resposta 18 de fev. de 2022
Respostas 2
Participantes 2