Jump to content
We've recently updated our Privacy Statement, available here ×

cel22262

Members
  • Posts

    2
  • Joined

  • Last visited

cel22262's Achievements

Newbie

Newbie (1/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Conversation Starter Rare

Recent Badges

0

Reputation

  1. Further investigation indicated the overall content of the file is correct. But I receive this nessage when I try to unzip the file: [....]# unzip x.docx Archive: x.docx End-of-central-directory signature not found. Either this file is not a zipfile, or it constitutes one disk of a multi-part archive. In the latter case the central directory and zipfile comment will be found on the last disk(s) of this archive. unzip: cannot find zipfile directory in one of x.docx or x.docx.zip, and cannot find x.docx.ZIP, period. I get the same error message on an .ODT file. If I open the .ODT with OpenOffice I get a message that the file is corrupted, but OO writer is able to repair it (similar message in MS Word with a .DOCX file)..... It would appear the the exporter is not properly closing the file and/or writing the correct trailer (central-directory).... Post Edited by cel22262 at 09/01/2011 20:14
  2. I have been sucessfully using the "XmlJasperInterface" code (originally written by Jonas Schwertfeger) to embed Jasper reports in my Rails application. I have recently tried to expand this code to include .docx, .xlsx, and .pptx exporters. The code compiles OK and executes with no errors generating a .docx file. Upon initial inspection of the output file, I see" PK..." markers as well as the various .xml sections, however the file fails to open with MS word or OO writer. When I try to unARK (unzip) the file I get the following message: [@Rift tmp]# /usr/bin/zipinfo -lT /tmp/Medical_Chronology10099233329.docx Archive: /tmp/Medical_Chronology-10099233329.docx [/tmp/Medical_Chronology-10099233329.docx] End-of-central-directory signature not found. Either this file is not a zipfile, or it constitutes one disk of a multi-part archive. In the latter case the central directory and zipfile comment will be found on the last disk(s) of this archive. zipinfo: cannot find zipfile directory in one of /tmp/Medical_Chronology-10099233329.docx or /tmp/Medical_Chronology-10099233329.docx.zip, and cannot find /tmp/Medical_Chronology-10099233329.docx.ZIP, period. [@Rift tmp]# The other exporters work fine (PDF, RTF, etc....) The attachments include the BROKEN.DOCX, the compile script and directory of the LIB directory(classpath) Any ideas/suggestion? BTW My OS environment is Linux (Mandriva 2010.2) Code:/* * An XML Jasper interface; Takes XML data from the standard input * and uses JRXmlDataSource to generate Jasper reports in the * specified output format using the specified compiled Jasper design. * * Inspired by the xmldatasource sample application provided with * jasperreports-1.1.0 */import net.sf.jasperreports.engine.JRException;import net.sf.jasperreports.engine.JRExporterParameter;import net.sf.jasperreports.engine.JasperExportManager;import net.sf.jasperreports.engine.JasperFillManager;import net.sf.jasperreports.engine.JasperPrint;import net.sf.jasperreports.engine.data.JRXmlDataSource;import net.sf.jasperreports.engine.export.JRCsvExporter;import net.sf.jasperreports.engine.export.JRRtfExporter;import net.sf.jasperreports.engine.export.JRXlsExporter;import net.sf.jasperreports.engine.export.JRXlsExporterParameter;// New Exporters added here..........import net.sf.jasperreports.engine.export.ooxml.JRDocxExporter;import net.sf.jasperreports.engine.export.ooxml.JRDocxExporterParameter;import net.sf.jasperreports.engine.export.ooxml.JRXlsxExporter;import net.sf.jasperreports.engine.export.ooxml.JRPptxExporter;import net.sf.jasperreports.engine.util.JRProperties;/** * @author Jonas Schwertfeger (jonas at schwertfeger dot ch) * @version $Id: XmlJasperInterface.java 97 2005-11-23 14:48:15Z js $ */public class XmlJasperInterface { private static final String TYPE_PDF = "pdf"; private static final String TYPE_XML = "xml"; private static final String TYPE_RTF = "rtf"; private static final String TYPE_XLS = "xls"; private static final String TYPE_CSV = "csv"; private static final String TYPE_DOCX = "docx"; private static final String TYPE_XLSX = "xlsx"; private static final String TYPE_PPTX = "pptx"; private String outputType; private String compiledDesign; private String selectCriteria; public static void main(String[] args) { String outputType = null; String compiledDesign = null; String selectCriteria = null; if (args.length != 3 && args.length != 4) { printUsage(); return; } for (int k = 0; k < args.length; ++k) { if (args[k].startsWith("-o")) outputType = args[k].substring(2); else if (args[k].startsWith("-f")) compiledDesign = args[k].substring(2); else if (args[k].startsWith("-x")) selectCriteria = args[k].substring(2); } XmlJasperInterface jasperInterface = new XmlJasperInterface(outputType, compiledDesign, selectCriteria); if (!jasperInterface.report()) { System.exit(1); } } public XmlJasperInterface( String outputType, String compiledDesign, String selectCriteria) { this.outputType = outputType; this.compiledDesign = compiledDesign; this.selectCriteria = selectCriteria; } public boolean report() { try { JasperPrint jasperPrint = JasperFillManager.fillReport(compiledDesign, null, new JRXmlDataSource(System.in, selectCriteria)); if (TYPE_PDF.equals(outputType)) { JasperExportManager.exportReportToPdfStream(jasperPrint, System.out); } else if (TYPE_XML.equals(outputType)) { JasperExportManager.exportReportToXmlStream(jasperPrint, System.out); } else if (TYPE_RTF.equals(outputType)) { JRRtfExporter rtfExporter = new JRRtfExporter(); rtfExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); rtfExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, System.out); rtfExporter.exportReport(); } else if (TYPE_XLS.equals(outputType)) { JRXlsExporter xlsExporter = new JRXlsExporter(); xlsExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); xlsExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, System.out); xlsExporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.TRUE); xlsExporter.exportReport(); } else if (TYPE_CSV.equals(outputType)) { JRCsvExporter csvExporter = new JRCsvExporter(); csvExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); csvExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, System.out); csvExporter.exportReport(); }// New Exporters added here.......... else if (TYPE_DOCX.equals(outputType)) { JRDocxExporter docxExporter = new JRDocxExporter(); docxExporter.setParameter(JRDocxExporterParameter.JASPER_PRINT, jasperPrint); docxExporter.setParameter(JRDocxExporterParameter.OUTPUT_STREAM, System.out); docxExporter.setParameter(JRDocxExporterParameter.FLEXIBLE_ROW_HEIGHT, Boolean.FALSE); docxExporter.setParameter(JRDocxExporterParameter.FRAMES_AS_NESTED_TABLES, Boolean.TRUE); docxExporter.exportReport(); } else if (TYPE_XLSX.equals(outputType)) { JRXlsxExporter xlsxExporter = new JRXlsxExporter(); xlsxExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); xlsxExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, System.out); xlsxExporter.exportReport(); } else if (TYPE_PPTX.equals(outputType)) { JRPptxExporter pptxExporter = new JRPptxExporter(); pptxExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); pptxExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, System.out); pptxExporter.exportReport(); } else { printUsage(); } } catch (JRException e) { e.printStackTrace(); return false; } catch (Exception e) { e.printStackTrace(); return false; } return true; } private static void printUsage() { System.out.println("XmlJasperInterface usage:"); System.out.println("\tjava XmlJasperInterface -oOutputType -fCompiledDesign -xSelectExpression < input.xml > report\n"); System.out.println("\tOutput types:\t\tpdf | xml | rtf | xls | csv | docx | xlsx | pptx"); System.out.println("\tCompiled design:\tFilename of the compiled Jasper design"); System.out.println("\tSelect expression:\tXPath expression that specifies the select criteria"); System.out.println("\t\t\t\t(See net.sf.jasperreports.engine.data.JRXmlDataSource for further information)"); System.out.println("\tStandard input:\t\tXML input data"); System.out.println("\tStandard output:\tReport generated by Jasper"); }}
×
×
  • Create New...