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

nirvanb

Members
  • Posts

    11
  • Joined

  • Last visited

nirvanb's Achievements

Apprentice

Apprentice (3/14)

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

Recent Badges

0

Reputation

  1. Load the jrxml file into a JasperDesign object in your program using JasperDesign design = JRXmlLoader.load then get the concerned element from the JasperDesign and modify its style as required. regards, Nirvan.
  2. I am trying to print with all margins set to "zero". But the printer is adding the margins to the report as a result of which the data is printed at an offset equal to the margins added by the printer . Any idea how to instruct to ignore all margins. regards, NIrvan.
  3. I have a cheque to print which has pageWidth="595" and pageHeight="269". While printing it seems that the jasper swaps the pageHeight and pageWidth if we supply orientation="Landscape" although I am not sure. The question I want to ask is whether the margins are swapped too ? i.e. side margins swapped with top and bottom margins. If this is true then the problem I am facing seems to be related to it. At design time in the jrxml, I have to following attributes pageHeight="269" pageWidth="595" topMargin="17" bottomMargin="17" leftMargin="17" rightMargin="36" columnWidth="540" The only band I have has the following <band height="235"> <textField> <reportElement x="464" y="0" width="70" height="42"/> <textElement verticalAlignment="Bottom"/> If I run the program, then the rightMargin (36) gets applied to topMargin when printed. So all the layout shifts down by the difference(36-17). How do I handle this situation. regards,Nirvan.
  4. Hi, I am trying to print cheque using jasper reports. The problem is that the areas (starting location, width, top, of say Date line) where I want to print the data varies to some extent. So I tried to set them using parameters, but it seems jasper reports does not support setting these attributes using parameters. Here is what I tried to do. <detail> <band height="$P{ChequeHeight}"> <textField> <reportElement x="$P{DateLeft}" y="$P{DateHeight}" width="$P{DateWidth}" height="30"/> ..... I get the following error when I try to validate jrxml. jasperreports.engine.JRException: org.xml.sax.SAXParseException: cvc-datatype-valid.1.2.1: '$P{ChequeHeight}' is not a valid value for 'NMTOKEN'.cvc-datatype-valid.1.2.1: '$P{DateLeft}' is not a valid value for 'NMTOKEN'. [41] cvc-attribute.3: The value '$P{DateLeft}' of attribute 'x' on element 'reportElement' is not valid with respect to its type, 'NMTOKEN'. [41] and same for DateHeight, and DateWidth. Any ideas for how to set the attributes dynamically. Also the height of the band needs to be set dynamically. regards,Nirvan
  5. I am trying to use a style template in my report template(jrxml file). The problem is that jasper reports framework is not able to locate my style template(.jrtx) file. I am using jasper reports 3.7.1 in my swing application. Here is what I have in my report template(.jrxml). <template> "/com/styles/template/styles.jrtx" </template> and here is the style template (.jrtx) <jasperTemplate> <style name="parentStyle" isDefault="true" fontName="Times New Roman" forecolor="blue" isBold="true" fontSize="13" pdfFontName="Helvetica-Bold"/> <style name="childStyle" fontSize="9" forecolor="red"/> </jasperTemplate> the styles template (styles.jrtx) is in the classpath, and I was expecting jasper reports to locate it. But it seems I am missing out something. regards, nirvan.
  6. For an EmptyDataSource, the attribute whenNoDataType="AllSectionsNoDetail" has to be set in order to avoid getting a blank report. cheers Nirvan
  7. I was trying to print a simple jasper report with a StaticText element in it. Here is my jrxml template. <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="FirstReport"> <detail> <band height="20"> <staticText> <reportElement x="20" y="0" width="200" height="20"/> <text> <![CDATA[Hello World of Jasper Reports]]> </text> </staticText> </band> </detail> </jasperReport> and here is the java code that compiles and views the report InputStream is = DesignViewer.class.getResourceAsStream("/com/jrxml/FirstReport.jrxml"); JasperReport designFile = JasperCompileManager.compileReport(is); JasperPrint printFile = JasperFillManager.fillReport(designFile, new HashMap(), new JREmptyDataSource()); JasperViewer.viewReport(printFile); The code compiles and runs without any Exceptions. But the StaticText is not printed and I get an empty report. Why is it not displaying the StaticText. Note: When I view the jrxml template using JasperDesignViewer, I am able to see only the hollow rectangles (band) but StaticText is again not displayed. regards, Nirvan
  8. There is no search algorithm used by compileReportToFile(String sourceFileName). Looking at the source code the compileReportToFile(String sourceFileName) calls JRXmlLoader.load(sourceFileName) which calls JRXmlLoader.load(new File(sourceFileName)) which creates InputFileStream based on the file passed to it. In short, it means that the file name passed as sourceFileName should be absolute system file name including path or be in the current directory from where the class is executed. I think that the other solutions discussed previously in the post has to be thought of and we could not directly rely on compileReportToFile(String sourceFileName) to find the jrxml file for us. I am very new to JasperReports and so I am not entirely confident making the above assumptions. regards, Nirvan.
  9. minhduc Wrote: Is a web application? When you deployed it on server, the File location and resource location are not same. If not, make sure com/jrxml/FirstReport.xml is located on your project folder, NOT in src folder. Anyway, I think you shoud use compileReport method and InputStream object. InputStream input = this.getClass().getResourceAsStream([your resource jrxml template ]); JasperDesign design = JRXmlLoader.load(input); JasperReport report = JasperCompileManager.compileReport(design); System.out.println("Template id loaded and complied"); JasperPrint print = JasperFillManager.fillReport(report, parameters, jRBeanArrayDataSource); System.out.println("Filled data"); JRExporter exporter = null; exporter = new JRXlsExporter(); Post Edited by minhduc at 04/02/2010 08:36 As mentioned in the question, I am developing a swing based application, not web based. I can use compileReport() as I can get a reference to InputStream. But looking ahead, I will require to store the .jasper compiled file so as to avoid re-compiling it again every time it is needed. regards, nirvan.
  10. Thanks for the reply, but unfortunately changing extension to jrxml still gives me the same File Not Found Exception. regards, nirvan.
  11. I am trying to create a .jasper file from an jrxml file using JasperCompileManager.compileReportToFile("jrxml file"). I am getting File Not Found Exception. I am not sure of the algorithm that the JasperCompileManager.compileReportToFile() is using to search the file to compile. I am able to locate the file in the java code using getResourceAsStream("/com/jrxml/FirstReport.xml"). Why is JasperCompileManager.compileReportToFile() unable to locate the file when the getResourceAsStream("/com/jrxml/FirstReport.xml") finds it successfully. My application is based on swing. regards nirvan.
×
×
  • Create New...