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

Apemant

Members
  • Posts

    4
  • Joined

  • Last visited

 Content Type 

Profiles

Forum

Events

Featured Visualizations

Knowledge Base

Documentation (PDF Downloads)

Blog

Documentation (Test Area)

Documentation

Dr. Jaspersoft Webinar Series

Downloads

Everything posted by Apemant

  1. Check the thread 'increasing fields dynamically' by sumankumar_alla, there you have some pointers. Good luck.
  2. Yes, .jrxml files are not required at all, but on the other hand, there might be some default report sections which don't need to be changed, so why not design those using iReport, load them with JRXmlLoader and then modify the resulting JasperDesign object? Anyway, there are static methods JRXmlLoader.load() which take either a File object, an InputStream or a String (name of a .jrxml file), which return a JasperDesign object that contains all the attributes and elements of the xml file. You could also just instantiate JasperDesign manually and then fill it with appropriate content. It does involve a lot of work but it is not complex or hard to understand. If you understand the elements and attributes from the Jasper XML scheme, then all the classes from net.sf.jasperreports.engine.design.* should be rather self-explanatory. For example, if you have a JasperDesign object like this JasperDesign jdes = new JasperDesign(); then you can add fields from your datasource like this: JRDesignField field = new JRDesignField(); field.setName("ADDRESS"); field.setValueClassName("java.lang.String"); jdes.addField(field); All the sections of a report (headers, footers, detail, title, summary) are defined by instantiating JRDesignBand object, set ting its height and adding report elements to it (JRDesignTextField, JRDesignLine, JRDesignWhatever) like this: JRDesignBand detail = new JRDesignBand(); detail.setHeight(16); // in points, 1/72 of an inch JRDesignTextField tf = new JRDesignTextField(); tf.setXXX(...); // set its various atributes detail.addElement(tf); // add the field to the band jas.setDetail(detail); // set the band as report detail section Anyway, there is a lot more to this, but you need to experiment on your own. Or buy the JasperReports Ultimate Guide. :) (I didn't buy it myself though, as reading API documentation or even source code seems enough for my needs) Have fun.
  3. I've seen topics with this issue before but no answers. Word wrapping in text fields is turned on by default and there is no way of turning it off. It is not so much of a problem if your textfield is supposed to grow (then you usually WANT it to be nicely wrapped), but if you need a text field to stay fixed height, and display as much text as possible in a line, then you wind up with half of your text eaten by the wrapping mechanism. Looking at the source code, I see it is the result of using java.awt.font's LineBreakMeasurer, the constructor without explicit BreakIterator argument, which then by default uses BreakIterator.getLineInstance(), for line wrapping at word boundaries. So, all that would be needed is to somehow make it customizable, perhaps adding a boolean flag (isWordWrap) to JRXXXTextField or even JRXXXTextElement classes and then create LineBreakMeasurer with different BreakIterator factory instances, depending on that flag. It seems strange to me that such a sophisticated tool lacks so simple a feature... when I considered moving to Jasper I looked at more advanced topics and it seemed to satisfy them all; now that I already built an old-reporting-tool-to-Jasper automatic converter and converted all my reports, I see that this annoying trifle is missing. Argh :S
  4. Yes, it is possible, but (I think) not with compiled reports, but with reports in design stage. What you need is JasperDesign class and other JRDesignXXX classes from the package net.sf.jasperreports.engine.design. An instance of JasperDesign can be programatically built from scratch, then you don't even need .jrxml files, but they can also be loaded from a .jrxml file (created with iReport for example) with JRXmlLoader. JasperDesign is actually a memory model with the sctucture equivalent to the corresponding .jrxml file. You can freely modify fields, elements, groups, variables, anything; but once you are finished you need to compile that JasperDesign object (either using JasperCompileManager or a compiler of your preference, I personally use JRJdk13Compiler) in order to get an instance of JasperPrint (which you normally load directly from a compiled .jasper file). It does create a small overhead, but in return you have practically endless possibilities of adjusting the final report to user requests. Of course, all of this assumes you use Java for modifying your reports. :) Hope this helps, if you have more questions, I'll be happy to answer.
×
×
  • Create New...