Duvidas com relatório![Resolvido]

4 respostas
danielbb

Bom dia galera,

Eu tenho uma aplicação que me gera um relatório em pdf, mas agora eu quero que me gere um documento em word.

Gostaria de saber se tem alguma maneira de fazer isso.

estou utilizando o ireport 3.6.0 para montar meu relatório.

Att.

4 Respostas

TheKill

o proprio iReport tem.

procure por Exporter na API

danielbb
Cara, sou novo nesse ramo e cai de paraquedas, mas eu procurei dentro da minha aplicação e achei o seguinte:
// Preeche VO de Arquivo e coloca na sessão para GET do evento donwload
			PlcArquivoVO arqVO = new PlcArquivoVO();

			String extensao = "";
			String tipo		= "";

			if (formato.equalsIgnoreCase("pdf")){
				extensao = ".pdf";
				tipo	 = "P";
				arqVO.setObjetoAuxiliar(PlcJasperExportManager.exportaParaPDF(plcJasperPrint));
			}
			else {
				if (formato.equalsIgnoreCase("xml")){
					extensao = ".xml";
					tipo	 = "X";
					arqVO.setObjetoAuxiliar(PlcJasperExportManager.exportaParaXML(plcJasperPrint).getBytes());
				}
				else{


					String diretorioRelatorios = PlcConfigControleHelper.getInstance().get("dirBaseRel");
					if (StringUtils.isBlank(diretorioRelatorios)) {
						throw new PlcException("jcompany.erro.gerarrelatorio.diretorio.temporarario.nao.informado");
					} else {
						if (debug) {
							log.debug("O diretório temporário informado no web.xml para relatório não é o ROOT do tomcat");
						}
					}

					if (formato.equalsIgnoreCase("html")){
						extensao = ".html";
						tipo	 = "H";
						String filePath = diretorioRelatorios+"rel"+extensao;
						PlcJasperExportManager.exportaParaHTML(plcJasperPrint, filePath);
					}
					else
						if (formato.equalsIgnoreCase("xls")) { // Excel (xls)
							extensao = ".xls";
							tipo	 = "X";

							String filePath = diretorioRelatorios+"rel"+extensao;
							File destFile = new File(filePath);

							PlcJRXlsExporter exporter = new PlcJRXlsExporter();
							exporter.setParameter(PlcJR[b]Exporter[/b]Parameter.JASPER_PRINT, plcJasperPrint.getJasperPrint());
							exporter.setParameter(PlcJRExporterParameter.OUTPUT_FILE_NAME, destFile.toString());
							exporter.setParameter(PlcJRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.TRUE);
							exporter.exportReport();
						}
						else
							if (formato.equalsIgnoreCase("csv")) { // Texto CSV - character separeted values
								extensao 	= ".csv";
								tipo	 = "C";
								String filePath = diretorioRelatorios+"rel"+extensao;
								File destFile = new File(filePath);

								String fieldDelimiter = null;
//								if (form.getMap().containsKey("fieldDelimiter")) {
//									fieldDelimiter = (String) form.get("fieldDelimiter");
//								}
								if (fieldDelimiter == null) {
									fieldDelimiter = ";";
								}

								PlcJRCsvExporter exporter = new PlcJRCsvExporter();

								exporter.setParameter (PlcJRExporterParameter.JASPER_PRINT, plcJasperPrint.getJasperPrint());
	 							exporter.setParameter (PlcJRExporterParameter.OUTPUT_FILE_NAME, destFile.toString());
								exporter.setParameter (PlcJRCsvExporterParameter.FIELD_DELIMITER, fieldDelimiter);
								exporter.setParameter (PlcJRCsvExporterParameter.CHARACTER_ENCODING, "ISO-8859-1");
								exporter.exportReport();

							}

					String path = diretorioRelatorios.substring(diretorioRelatorios.lastIndexOf("\\"),diretorioRelatorios.length());
					path =	"/" + path.substring(1,path.length()) + "/rel" +extensao;
					response.sendRedirect(path);
					return null;
				}
			}
TheKill

ao invés deste P1cJasperExportManager

faça uma pesquisa e utilize este aqui > JRDocxExporter
é esta API que deve utilizar, mas vai ter que pesquisar :wink:

nunca usei ela, não tive necessidade ainda ^^
Mas é esta.

danielbb

blz, vou procurar aqui, obrigado pela atenção!

Criado 24 de maio de 2010
Ultima resposta 7 de jun. de 2010
Respostas 4
Participantes 2