I would like to create a report that has the following layout:
It has three parts as you can see. The third part is a subreport done as a list, that is the easy part! My question is this: is there a better way of doing the first two parts than drawing boxes and lines in element groups and doing crazy calculations with positioning them? (I am talking about the .jrxml)
Try using iReport. It is a gui application for designing jasper reports.
You can drag and drop text fields and other report elements, so you don't have to worry about positioning.
I have had several problems using the .jrxml gerenated by iReport, but finally I have found an artikle that explains how to use iReport. It also explains how to fill the report.
I have had problems since I was using a manually written .jrxml, which had to be compiled and filled. Now based on the code in the artikel I am not using .jrxml anymore, but the .jasper file compiled by the iReport and everything works like a charm.
Related
I've been having issues using POI-3.10-FINAL where editing a PPTX doesn't fully work. I noticed that I am successfully able to add new slides, but modifications to shapes (in this case, a table) aren't reflected in the outputted PPTX file.
I was able to fix it by switching from poi-ooxml-schemas-*.jar to ooxml-schemas-1.1.jar but the resulting PPTX file seems to be corrupted: PowerPoint 2007 fails to open it but PowerPoint 2010 repairs it first, then properly opens it.
In investigating the issue, I noticed that the "docProps/app.xml" is not being updated correctly (I'm assuming other files within the PPTX aren't being updated as well).
Any ideas?
I've been able to properly troubleshoot and fix my POI issues using Microsoft's OpenXml SDK (see OpenXml SDK). The SDK helps you scan through a PPTX file (or any other OpenXml document) and compiles a list of all errors it finds.
In my case, I was setting one of my table cell's text value to null. In turn, POI generated the xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" declaration at the top most slide tag and used xsi:nil="true" within the cell's tag which PowerPoint absolutely did not like.
Another issue I was having was that I was modifying and creating new rows and columns within my table. To make things easier in my code, whenever I did anything to a cell, I made sure I set the border information to black with a width of 1 and the fill color to white. For some odd reason it seems that POI was not replacing the border information, but appending it which made the PPTX have 2 conflicting values rather than 1 (I have to investigate this one further but checking the border and fill information before trying to set them definitely fixed my issue).
These issues were rather easy to fix once I figured them out.
I have a JTextArea, and I have this being populated with a chosen .java file, the problem is that the file is appearing as just normal text. I would like to add some pretty print so that the user will be able to see the file as if the file was open in eclipse (keywords different color, comments will be in grey... etc)
I have not been able to find any good examples online for how to do this. what would be the best way to do this?
EDIT:
I got this to finally work, i added the JSyntaxPane jar file to my classpath (jsyntaxpane-0.9.5-b29.jar to be exact) then i added the following two lines of code to get it working for my JEditorPane.
jsyntaxpane.DefaultSyntaxKit.initKit();
JEditorPane.setContentType("text/java");
This can also be used on the following languages: JavaScript, Properties, Groovy, C, C++, XML, SQL, Ruby and Python... just by simply changing text/java to text/LANGUAGE_YOU_WANT in the above code
JTextArea can only display plain text (like notepad in Windows). If you want to show pretty printed source code with colors, you need JEditorPane, which allows you to display HTML.
Now you can either generate HTML manually with syntax-highlighted Java source code or use some library.
See also
Where can I find a syntax highlighting library for Java?
JEdit-Syntax has a JEditTextArea class that will do syntax highlighting. This project was spun off to package some subcomponents of the JEdit project.
I have some troubles with JasperReports. I generated a formular with iReport including two subreports which generates a grid of values (1 or 2 Characters long).
The compiled PDF from iReport it works fine and looks good, but if i use the same *.jrxml and *.jasper files for my web app the generated PDF has some minor differences. One big problem is, that some cells of the grid now are 2 lines high. Values like "NB" only use one line but "GS" for example uses 2 lines.
For me it is not possible to find the error. Workarounds with smaller font size or wider cells didn't help.
Make sure the font you are using in the template is available on the JVM generating the report. If the font doesn't exist then a different font will be used. If changing the font isn't an option then you can create a font extension package. Creating a font extension is documented here: JasperReports Font Reference
Sound like you could have a different version of iReports in your web application. Making the cells sufficiently wide enough should at least allow the text to span just one line.
Create a Java Desktop test that generates a PDF based on the .jrxml and make sure it has the same results. If it does then there is something with the way iReports is working, if it doesn't then you know it is something with how you are viewing or creating the PDF in the web app.
This is for my Java programming assignment, and I've only been working with Java for about 3 months.
We need something simple, so I thought of going with a program that allows the user to customise and design a greeting card cover. Not too complex, it's an introductory course. I would really like some guidelines on how to go about this, and if there is some existing code available. We are allowed to refer to existing codes to create our program as long as we include it as a reference.
So far I can only think of something that can allow custom borders, or a bunch of existing borders as options, fonts, colours and background choices, either colours or textures.
I would appreciate all the help I can get. Thanks.
You could use Jasper reports and create different templates with thumbnails for greeting cards. User would fill the required fields and select thumb of report template. You would then load and preview the selected report.
If you would like more complex solution, you could create "plugin engine" which would allow user to load custom Jasper report templates. You could then save the plugin reports data in xml file. That should be more than enough for any school project.
You could use your knowlege in any future project since you would learn how to create reports, how to create xml files and a lot more ... Most application today use reports and xml files so it would be more than useful knowledge.
The thing I am doing is displaying Jasper Report in an JApplet in web browser. Eeverything is working fine except two.
The detail section of my report is not showing up in the applet. I'm sure that there is no issue with the report filling as the values of query fields put in other sections like page header are showing up. Only the detail section is missing. Can anyone give some idae about the cause?
The SAVE button of the JR Viewer in the applet is not working. Any comments?
About the first question, the Detail section (unlike other sections) is related to the Data Query of the entire report. So you should make sure the report query is returning at least one record for the Detail section to appear.
Suggestion, you can export your report to PDF and open it using the browser, I believe this would be better than loading an Applet each time.