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

jwsmith22

Members
  • Posts

    8
  • Joined

  • Last visited

jwsmith22's Achievements

Rookie

Rookie (2/14)

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

Recent Badges

0

Reputation

  1. Have you tried setting the content type simply to "application/excel"? Of course, I am not familiar with what "vnd.ms-excel" is so I am not sure.
  2. Here is what I do to output to a pdf viewer, I would assume that you can do the same thing with Excel... Code: public void printPreview() throws SettingsException, IOException, JRException { //Get the path to the viewing application String pdfViewer = Settings.getSetting("pdfViewer",""Foxit Reader""«»); //log... classLogger.debug(pdfViewer); //create a temporary file in the system's temp file space File tempFile = File.createTempFile("tmp",".pdf"«»); //Export to the temporary file... JasperExportManager.exportReportToPdfFile(jasperPrint,tempFile.getAbsolutePath()); classLogger.debug(tempFile.getAbsolutePath()); pdfViewer = """ + pdfViewer + """; String[] command = new String[2]; tempFile.deleteOnExit(); //At some point make sure both Path's are surrounded with "" to account for spaces command[0] = pdfViewer ; command[1] = """ + tempFile.getAbsolutePath() + """; //execute your viewer Runtime.getRuntime().exec(command); }
  3. I have seem to hit a wall, I must be forgetting something here. I have added a 3dPie Chart to a report. I am using iReport to design the report, I test the build of the report against an XML data source, the preview works just fine. However, when I copy the report template to my project and try to execute from my program, I get a null pointer exception. here is the StackTrace: 16:36:46,463 DEBUG JRBaseFiller:342 - Fill 27754609: created for ProgramUsageSummary 16:36:46,531 DEBUG JRBaseFiller:707 - Fill 27754609: filling report 16:36:46,534 DEBUG JRFillDataset:675 - Fill 27754609: Creating xPath query executer 16:36:46,536 DEBUG JRXPathQueryExecuter:89 - XPath query: /Table/Record[*] Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at org.apache.commons.beanutils.locale.LocaleConvertUtilsBean.convert(LocaleConvertUtilsBean.java:235) 16:36:46,693 DEBUG JRFillDataset:738 - Fill 27754609: closing query executer at net.sf.jasperreports.engine.data.JRXmlDataSource.getFieldValue(JRXmlDataSource.java:338) at net.sf.jasperreports.engine.fill.JRFillDataset.setOldValues(JRFillDataset.java:813) at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:777) at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:1106) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:111) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:763) at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:123) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:420) at com.Summit.util.ReportUtility.<init>(ReportUtility.java:57) at com.Summit.Sequence.defaults.gui.DefaultProgramMaintenanceFrame.jButton2ActionPerformed(DefaultProgramMaintenanceFrame.java:170) at com.Summit.Sequence.defaults.gui.DefaultProgramMaintenanceFrame.access$300(DefaultProgramMaintenanceFrame.java:38) at com.Summit.Sequence.defaults.gui.DefaultProgramMaintenanceFrame$4.actionPerformed(DefaultProgramMaintenanceFrame.java:148) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236) at java.awt.Component.processMouseEvent(Component.java:6038) at javax.swing.JComponent.processMouseEvent(JComponent.java:3260) at java.awt.Component.processEvent(Component.java:5803) at java.awt.Container.processEvent(Container.java:2058) at java.awt.Component.dispatchEventImpl(Component.java:4410) at java.awt.Container.dispatchEventImpl(Container.java:2116) at java.awt.Component.dispatchEvent(Component.java:4240) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916) at java.awt.Container.dispatchEventImpl(Container.java:2102) at java.awt.Window.dispatchEventImpl(Window.java:2429) at java.awt.Component.dispatchEvent(Component.java:4240) at java.awt.EventQueue.dispatchEvent(EventQueue.java:599) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160) at java.awt.EventDispatchThread.run(EventDispatchThread.java:121) The Code that gets this is as follows: Code: try { report = JasperCompileManager.compileReport( getReportTemplate(reportTemplate)); HashMap params = new HashMap(); DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document doc = builder.parse(new ByteArrayInputStream(xmlData.getBytes())); params.put(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT, doc); jasperPrint = JasperFillManager.fillReport(report, params); } catch (IOException ex) { throw new ReportException(ex.getMessage()); } catch (SAXException ex) { throw new ReportException(ex.getMessage()); } catch (JRException ex) { throw new ReportException(ex.getMessage()); } catch (ParserConfigurationException ex) { throw new ReportException(ex.getMessage()); } Any insight would be greatly appreciated. Thanks
  4. If you are using iReport, it has a great XPath tool in it, it will highlight the parent nodes that your XPath query will select. I am not an XPath expert by any means, but you may try the query "/MyReport/*/*" This XPath query will select all fields 2 deep from the root of MyReport. Check w3Schools.com for a good reference. Post edited by: jwsmith22, at: 2007/08/02 19:30
  5. That worked perfectly for my issue, thank you very much. I knew there had to be another way around it.
  6. Three things that helped me out on this problem, 1) http://w3schools.com/xpath/default.asp That has everything you need (or don't need) for XPath. 2) XMLDataSource examples in the demo folder of the distribution 3) This was the big one, in iReport, you can specify a data source and an XPath query. I knew that once the template file got saved, it lost the data source (it assumes you will be giving it a proper data source later). The .jrxml file has a reference to the XPath inside it when it is saved, but when you create the XMLDataSource object without an XPath argument, it doesn't seem to default to the template's query. The only work around that I have found is to specify the correct XPath query with the XML input. It would seem this would not be the best way to do this, so if anyone else has a better solution, please help us out. I would like for the specified query from the report template be used, instead of having to specify one in the data source. Code: //TODO Figure a way around forcing the select statement. //This will make the generic class much more robust. JRXmlDataSource source = new JRXmlDataSource(xmlInStream,"/Report/Record"«»);
  7. I am having this same issue, if I can find the solution, I will post it here.
×
×
  • Create New...