Jump to content
Changes to the Jaspersoft community edition download ×

burferd

Members
  • Posts

    87
  • Joined

  • Last visited

burferd's Achievements

Collaborator

Collaborator (7/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Collaborator Rare

Recent Badges

0

Reputation

  1. I hve built a report using the iReport 4.5.0 plugin for NetBeans. The report displays fine when I use the Preview, but I am having problems getting the report to display in my application. I have used the code below to display reports before and it gives a note to the browser to save or open the report, but for this one, it does not seem to work. Any suggestions as to what I am doing wrong? Java code to create/display a PDF file. public boolean createSafetySummaryRpt() { System.out.println("<ReportSessionBean.createSafetySummaryRpt> doPdf = "+doPdf+", doExcel = "+doExcel); JasperPrint jp = null; try { Map parameters = new HashMap(); String rptFile = rptPath+"SafetySummaryRpt.jasper"; jp = JasperFillManager.fillReport( rptFile, parameters, sb1.getDbConnection() ); if( doPdf )doPdfReport( jp, "SafetySummary"); if( doExcel )doExcelReport( jp, "SafetySummary" ); } catch( Exception e ) { e.printStackTrace(); System.out.println( "<ReportSessionBean.createUserRpt> Error: "+ e.toString()); sb1.setMessage( "Error creating report."); return false; } return true; } public void doPdfReport( JasperPrint reportout, String filename ) { byte[] pdf =null; try { pdf = JasperExportManager.exportReportToPdf(reportout); } catch (JRException ex3) { System.out.println("Couldn't create PDF: "+ex3); } FacesContext faces = javax.faces.context.FacesContext.getCurrentInstance(); HttpServletResponse response =(HttpServletResponse)faces.getExternalContext().getResponse(); System.out.println("<ReportSessionBean.doPdfReport> " ); response.setContentType("application/pdf"); response.setContentLength(pdf.length); response.setHeader("Content-disposition","attachment; filename=\""+filename+".pdf\""); ServletOutputStream out; try{ out = response.getOutputStream(); out.write(pdf); System.out.println("<ReportSessionBean.doPdfReport> after out.write " ); }catch (Exception qw){ System.out.println("Could not output file:"+qw); } faces.responseComplete(); } Here is the report I am tryong to use.: <?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="SafetySummaryRpt" language="groovy" pageWidth="792" pageHeight="612" orientation="Landscape" columnWidth="752" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20"> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="0"/> <queryString language="SQL"> <![CDATA[sELECT tbSafetySummary."dtLoadTime" AS tbSafetySummary_dtLoadTime, tbSafetySummary."vcDeviceName" AS tbSafetySummary_vcDeviceName, tbSafetySummary."dcHardBraking" AS tbSafetySummary_dcHardBraking, tbSafetySummary."dcRapidStarts" AS tbSafetySummary_dcRapidStarts, tbSafetySummary."dcSpeeding" AS tbSafetySummary_dcSpeeding, tbSafetySummary."iNightDrivingMins" AS tbSafetySummary_iNightDrivingMins, tbSafetySummary."iIdlingMins" AS tbSafetySummary_iIdlingMins, tbSafetySummary."iAvgMPG" AS tbSafetySummary_iAvgMPG, tbSafetySummary."iGPSLocks" AS tbSafetySummary_iGPSLocks, tbSafetySummary."dcTotalTravelTime" AS tbSafetySummary_dcTotalTravelTime, tbSafetySummary."iTotalTravelMiles" AS tbSafetySummary_iTotalTravelMiles, tbSafetySummary."iOverallScore" AS tbSafetySummary_iOverallScore, tbSafetySummary."iSafetySummaryId" AS tbSafetySummary_iSafetySummaryId FROM "dbo"."tbSafetySummary" tbSafetySummary]]> </queryString> <field name="tbSafetySummary_dtLoadTime" class="java.sql.Timestamp"/> <field name="tbSafetySummary_vcDeviceName" class="java.lang.String"/> <field name="tbSafetySummary_dcHardBraking" class="java.math.BigDecimal"/> <field name="tbSafetySummary_dcRapidStarts" class="java.math.BigDecimal"/> <field name="tbSafetySummary_dcSpeeding" class="java.math.BigDecimal"/> <field name="tbSafetySummary_iNightDrivingMins" class="java.lang.Integer"/> <field name="tbSafetySummary_iIdlingMins" class="java.lang.Integer"/> <field name="tbSafetySummary_iAvgMPG" class="java.lang.Integer"/> <field name="tbSafetySummary_iGPSLocks" class="java.lang.Integer"/> <field name="tbSafetySummary_dcTotalTravelTime" class="java.math.BigDecimal"/> <field name="tbSafetySummary_iTotalTravelMiles" class="java.lang.Integer"/> <field name="tbSafetySummary_iOverallScore" class="java.lang.Integer"/> <field name="tbSafetySummary_iSafetySummaryId" class="java.lang.Integer"/> <background> <band splitType="Stretch"/> </background> <title> <band height="25" splitType="Stretch"> <staticText> <reportElement x="231" y="0" width="286" height="23"/> <textElement textAlignment="Center"> <font size="16" isBold="true" isUnderline="true"/> </textElement> <text><![CDATA[safety Summary Report]]></text> </staticText> </band> </title> <pageHeader> <band splitType="Stretch"/> </pageHeader> <columnHeader> <band height="27" splitType="Stretch"> <staticText> <reportElement x="0" y="0" width="195" height="26"/> <textElement> <font isBold="true" isUnderline="true"/> </textElement> <text><![CDATA[Device Name]]></text> </staticText> <staticText> <reportElement x="195" y="0" width="60" height="26"/> <textElement textAlignment="Right" verticalAlignment="Middle"> <font isBold="true" isItalic="false" isUnderline="true"/> </textElement> <text><![CDATA[Hard Braking]]></text> </staticText> <staticText> <reportElement x="260" y="0" width="55" height="26"/> <textElement textAlignment="Right" verticalAlignment="Middle"> <font isBold="true" isUnderline="true"/> </textElement> <text><![CDATA[Rapid Starts]]></text> </staticText> <staticText> <reportElement x="315" y="0" width="60" height="26"/> <textElement textAlignment="Right" verticalAlignment="Middle"> <font isBold="true" isUnderline="true"/> </textElement> <text><![CDATA[speeding]]></text> </staticText> <staticText> <reportElement x="375" y="0" width="70" height="26"/> <textElement textAlignment="Right" verticalAlignment="Middle"> <font isBold="true" isUnderline="true"/> </textElement> <text><![CDATA[Night Driving Minutes]]></text> </staticText> <staticText> <reportElement x="445" y="0" width="60" height="26"/> <textElement textAlignment="Right" verticalAlignment="Middle"> <font isBold="true" isUnderline="true"/> </textElement> <text><![CDATA[idling Minutes]]></text> </staticText> <staticText> <reportElement x="505" y="0" width="60" height="26"/> <textElement textAlignment="Right" verticalAlignment="Middle"> <font isBold="true" isUnderline="true"/> </textElement> <text><![CDATA[Average MPG]]></text> </staticText> <staticText> <reportElement x="565" y="0" width="60" height="26"/> <textElement textAlignment="Right" verticalAlignment="Middle"> <font isBold="true" isUnderline="true"/> </textElement> <text><![CDATA[GPS Locks]]></text> </staticText> <staticText> <reportElement x="625" y="0" width="65" height="26"/> <textElement textAlignment="Right" verticalAlignment="Middle"> <font isBold="true" isUnderline="true"/> </textElement> <text><![CDATA[Total Travel Time]]></text> </staticText> <staticText> <reportElement x="690" y="0" width="62" height="26"/> <textElement textAlignment="Right" verticalAlignment="Middle"> <font isBold="true" isUnderline="true"/> </textElement> <text><![CDATA[Total Travel Miles]]></text> </staticText> </band> </columnHeader> <detail> <band height="16" splitType="Stretch"> <textField> <reportElement x="0" y="0" width="195" height="15"/> <textElement/> <textFieldExpression><![CDATA[$F{tbSafetySummary_vcDeviceName}]]></textFieldExpression> </textField> <textField> <reportElement x="195" y="0" width="60" height="15"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$F{tbSafetySummary_dcHardBraking}]]></textFieldExpression> </textField> <textField> <reportElement x="255" y="1" width="60" height="15"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$F{tbSafetySummary_dcHardBraking}]]></textFieldExpression> </textField> <textField> <reportElement x="315" y="0" width="60" height="15"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$F{tbSafetySummary_dcSpeeding}]]></textFieldExpression> </textField> <textField> <reportElement x="375" y="0" width="70" height="15"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$F{tbSafetySummary_iNightDrivingMins}]]></textFieldExpression> </textField> <textField> <reportElement x="445" y="1" width="60" height="15"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$F{tbSafetySummary_iIdlingMins}]]></textFieldExpression> </textField> <textField> <reportElement x="505" y="0" width="60" height="15"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$F{tbSafetySummary_iAvgMPG}]]></textFieldExpression> </textField> <textField> <reportElement x="565" y="0" width="60" height="15"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$F{tbSafetySummary_iGPSLocks}]]></textFieldExpression> </textField> <textField> <reportElement x="625" y="0" width="65" height="15"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$F{tbSafetySummary_dcTotalTravelTime}]]></textFieldExpression> </textField> <textField> <reportElement x="690" y="1" width="62" height="15"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$F{tbSafetySummary_iTotalTravelMiles}]]></textFieldExpression> </textField> </band> </detail> <columnFooter> <band height="45" splitType="Stretch"/> </columnFooter> <pageFooter> <band height="54" splitType="Stretch"/> </pageFooter> <summary> <band height="42" splitType="Stretch"/> </summary> </jasperReport>
  2. Thanks for the feedback. With the Netbeans module, is there any way to have it reference my source code package, or do I still need to create a jar file for that package? I have two packages that need to be accessed - one with the database references and the other with the bean wrappers that access the database references. Would I be able to add more than one jar file in the classpath? One other option that I have seen is to use a Hibernate data source. I am using hibernate, but have not figured out how to use that as a datasource. Any suggestion on how I can make that connection in the Netbeans plugin? Netbeans has the all the hibernate info. Can iReport link in to that?
  3. I am pretty new to iReports, but I need to create several reports using Javabeans as the datasource. I found this reference: http://knol.google.com/k/jasper-reports-working-with-beans-and-sub-report In this, the author mentions that he created a jar file of the classes and placed that jar file in the "lib" directory. After doing that, he was able to access the bean properties from within iReport. This is where he lost me. Can anyone fill me in on details of how I might access the classes of a NetBeans project in iReport 4.5.0 (or something similar). I have both the stand-alone version and the NetBeans plugin, but have not been able to figure out how to access the bean properties in the iReport framework. Thanks.
  4. I am programming in Java. To create the connection, I opened the "Services" window by clicking on the "Window" option in the iReport main menu bar and selecting "Services". This displayed the "Services" window on the left side of iReport. In the "Services" window, I expanded the "Database" tree by clicking on the "Database" icon. In this tree, I did a Left click on the "Drivers" icon and selected the "New Driver" option from the popup menu. That displayed a "New JDBC Driver" dialog box. In that box, I clicked the "Add" button and navigated to where my SQL Server driver jar file is located. I selected that driver and clicked the "OK" button. That added the driver I just selected to the list of Drivers in the Services window. I then left clicked on the "Database" icon in the Services Window and selected the "New Connection" option. This brought up the "New Connection" dialog. I entered the Username, Password, and JDBC URL that is used in the application. I clicked OK, and iReport attempted to make the connection, but never could. I did these same steps for my Oracle driver and it worked just fine. I know the SQLServer driver, username, password, and JDBC URL are correct, because I can make the database connection in NetBeans and in my application. I want the connection in order to create a Jasper Report that I can call from my Java web application using the data in the database for information on the report.
  5. In the Services window, I added the driver in the Databases -> Drivers section. Does that not add the library to the classpath? If not, then how do I add it? I did this to add an Oracle driver and that allowed me to make a connection in iReport, but not the SQL Server driver. I'm not familiar with the jtds-1.2.5.jar file you mention. I wold prefer to use the same drivers that I use for my application, however.
  6. I figured out a work around. I loaded the NetBeans plugin, created a connection in NetBeans and then used the NetBeans connection option. That seems to work, but I still do not know why what I did above fails.
  7. I just downloaded the latest version of Jasper Reports and iReport and am attempting to create a new database connection to my SQL Server database. I am using this driver: sqljdbc4.jar and added the driver to the Databases->Drivers section in the Services window. I then attempted to create a new database connection using the connection information that works in my application. In the New Connection dialog, I tried both the Field Entry and Direct URL Entry methods. In both cases, when I fill out the connection information and push OK, the dialog greys out with only the Cancel and Help buttons active. I suspect it is attempting to create the connection, but apparently never does. The database is active and I can connect to it with both my application and the SWL Server Management Studio using the information I entered for the connection in iReport. Is there a problem with creating SQL Server database connections in iReport 4.5.0? Any suggestions on how I can create the database connection? Should I back off to an older version of iReport? Thanks
  8. I am attempting to run the 4.0.1 demo report "TableReport.jrxml" from http://jasperreports.sourceforge.net/sample.reference/table/index.html When attempting to execute JasperCompileManager.compileReport() I get the following exceptiion: Parse Error at line 9 column 66: Document root element "jasperReport", must match DOCTYPE root "null". I'm using the TableReport.jrxml file that is in the demo example - attached below. I have modified the compile step to match my application - the code for that is included below. I think it is correct, since I can make it work with simple jrxml files from an older iReport test. I believe it is a problem with the syntax in the first <jasperReport> definition, but I do not know what the proper syntax should be. Can anyone point me to a table example that will work? I am using JR 4.0.2 libraries. Thanks. Code: public boolean createAccountInfoRpt() { JasperPrint jp = null; JasperReport rptFile = null; try { Map parameters = new HashMap(); parameters.put("TableDataSource", new JREmptyDataSource(50)); rptFile = JasperCompileManager.compileReport("C:/Reports/Greenville/Source/TableReport.jrxml"); System.out.println( "<SessionBean1.createAccountInfoRpt> Compiled Jasper Report "+rptFile ); jp = JasperFillManager.fillReport( rptFile, parameters, new JREmptyDataSource() ); if( doPdf )doPdfReport( jp, "AccountInformation"); if( doExcel )doExcelReport( jp, "AccountInformation" ); } catch( Exception e ) { e.printStackTrace(); System.out.println( "<SessionBean1.createAccountInfoRpt> Error: "+ e.toString());// setMessage( "Error creating report."); return false; } return true; }
  9. Still having problems - when I add a text field and parameter, I still the the following classCastException: java.lang.ClassCastException: cannot assign instance of net.sf.jasperreports.engine.base.JRBaseStaticText to field net.sf.jasperreports.engine.base.JRBaseLineBox.boxContainer of type net.sf.jasperreports.engine.JRBoxContainer in instance of net.sf.jasperreports.engine.base.JRBaseLineBox Can anyone tell me what I need to do in order to get a jasper report to work? I'm using the following lbraries: commons-beanutils.1.8.0.jar commons-collections-2.1.1.jar commons-digester-1.7.jar commons-logging-1.0.4.jar groovy-all.1.7.5.jar poi-3.6.jar jasperreports-3.7.6.jar (i used jasperreports-4.0.2.jar when testing 4.0.2).I'm working on Windows (same result on XP and Windows 7-64 bit), using NetBeans 6.9.1 and 7.0, Glassfish 3.0 and 3.2. Is there any kind of permission I need to set for the server? I'm sure there has to be someone out there who has been able to make this work. I'm really at a loss to figure this out. Any help is appreciated. Thanks.
  10. I can also use a report build with iReport 3.7.6 and I do not get this error, but I also do not get bold fonts for some reason. Am I the only one who has a problem running a report created with iReport 4.0.2 in a java application linked to the jasperreport-4.0.2.jar file? Something is not right here.
  11. I created a report using an old version of iReport (1.3.2) and was able to get past this error for a test report that used parameters. Apparently, the problem is because the test report was created using iReport 4.0.2. I don't understand this, unless I am missing a library somewhere. Any clues? Thanks.
  12. I'm seeing this error when attempting to create an excel report using JR 4.0.2 and POI 3.6.
  13. I am working on a report that I built using iReport 4.0.2. It looks like I am taking a step backwards. I thought I had a report working with static text, but apparently not. I created a report that is just a blank page and that works fine. I added a single static text field and I get an exception when attempting to do execute JasperFillManager.fillReport(). It looks like it is trying to cast a JRBaseStaticText field to another type. Can anyone shed some light on what is happening and how I can get rid of this error? I have attached the code I am using, thje jrxml file, and the pdf outpur from iReport to show what I was trying to create. Thanks Code: Code: public void createTestRpt() { JasperPrint jp=null; JasperReport jr = null; try { Map parameters = new HashMap(); String rptFile = "C:/Reports/Greenville/Source/report3.jasper"; jp = JasperFillManager.fillReport( rptFile, parameters, new JREmptyDataSource() ); if( doPdf )doPdfReport( jp, "TestReport"); if( doExcel )doExcelReport( jp, "TestReport" ); } catch( Exception e ) { e.printStackTrace(); System.out.println( "<SessionBean1.createTestRpt> Error: "+ e.toString()); } } Post Edited by burferd at 06/24/2011 21:05
  14. I am having the same problem as well. I don't see it in the iReport previewer, but when I generate a PDF - see attached. Accoount Information should be on one line; The colon is split on Pin: and Phone: The l is split from the word Model in the table. Post Edited by burferd at 06/23/2011 17:25
  15. I am trying to generate a PDF and Excel version of the same report. I am able to generate the PDF version, but get the error shown in the code section when I try to do the Excel version. It appears that it can't find something i the poi library: org.apache.poi.hssf.usermodel.HSSFWorkbook.getCreationHelper() I thought I had all the proper libraries loaded, but maybe I am missing something. Here are the libraries I have loaded: commons-beanutils-1.8.0.jar commons-collections-2.1.1.jar commons-digester-1.7.jar commons-logging-1.0.4.jar jasperreports-4.0.1.jar groovy-all-1.7.5.jar iText-2.1.7.jar poi-3.6.jar Could anyone tell me what I am missing that caused the error? Thanks. PS. I found a post on this problem using JR4.0.0. They said that using POI-3.6 solved the problem. however, I have POI-3.6 in my library list and still get the error. Here is the post: http://jasperforge.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=84285 Code: Post Edited by burferd at 06/23/2011 17:44
×
×
  • Create New...