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

rsilverns.sympatico.ca

Members
  • Posts

    151
  • 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 rsilverns.sympatico.ca

  1. I asked this question previously but did not get a response... Can you comment on the timeframe (if any) for adopting multiple page layouts within one report in jasper? i.e. having a portrait page then a landscape page in the same report? Thx, Rob
  2. Did you try #1 that I listed in my original response? It seems to be the best suited solution to this problem. I don't think its possible to not embed the queryString into the sub-report since the contents of that subreport are 100% dependant on the current value of the grouped elements (ID and name). I mean, I don't know how to make in java the connection between the report and the subreport. To do this, pass the datasource to the sub-report as a parameter in the main reports parameter hashmap. This datasource would have to be a resultset datasource since you want to avoid embedding queryStrings in your reports. To fill the report you would use... Code: public boolean exportReport(JRResultSetDataSource ds, JRResultSetDataSource subReportDS, File outputFile) { JasperReport jasperReport; JasperPrint jasperPrint; try { jasperReport = JasperCompileManager.compileReport("c:\main_report.jrxml"«»); Map customParameters = new HashMap(); customParameters.put("SubReportDataSource", subReportDS); jasperPrint = JasperFillManager.fillReport( jasperReport, customParameters, ds); JasperExportManager.exportReportToPdfFile( jasperPrint, outputFile.toString()); } catch (JRException e) { recordMessage("There was an error filling the report. Message given: " + e.getMessage(), TYPE_ERROR); return false; } return true; } Both of the datasources would be resultset datasources that you created based upon the needs of your report. Now the problem is that your dataset for the subreport is static, it will not change with each individual ID-Name combo that is in the header for each sub-report. So the sub-report will not be accurate. HTH, Robin
  3. Can you post the report? Are you putting the fields in the headers as opposed to the detail band by chance? HTH, Robin
  4. When dealing with CSV file output, remember that the jasper algorithm for deciding the format of the output is quite strict. You want to make sure to align your fields on the same vertical space and try not to have too many levels(vertical levels that is) of data. Review the FAQ at Code:http://jasperforge.org/sf/wiki/do/viewPage/projects.jasperreports/wiki/FAQ9for a detailed explanation of how the report layout is calculated. HTH, Robin
  5. After you do the manual merge, what about returning the stream to the browser when they click on a link, and have it be type/pdf for content. It is not a "preview" per se.. but may do the trick. That was going to be my approach once I reached that stage on this report/project. HTH, Robin
  6. So to summarize the DB structure... Clients: CID | Name 1 | Joe 2 | Frank 3 | Bob Products: PID | ClientID | ProductDescr 1 | 1 | Toaster 2 | 1 | Kettle 3 | 2 | David Hassellhoff CD (It could happen!) There are 2 ways i see to address this problem... 1. Don't use a sub-report in this instance but combine both tables using a join SQl statement and use groups in 1 main report. i.e. SELECT Clients.ID, Clients.Name, Products.ProductDescr FROM Products, Clients WHERE Clients.ID = Products.ClientID. Note: this sql is off top of my head so be sure to double check it. :) So now your result set would be.... ID, Name, ProductDescr So group by ID and Name and then list each product descr in the detail band for what they bought... example output: Purchaser ID: 1 Purchaser Name: Frank ------------------------------- (detail band start) * Toaster * David Hassellhoff CD (oh the shame!) 2. The second approach is to pass the sub-report the main datasource as a parameter. But this means embedding the query into the jrxml file for the main and sub-report. In this case, the datasource would be a Connection object. Then you would parameterize the sub-report query by client ID... something like SELECT ProductDescr from Products where ClientID=$P!{CLIENT_ID_PARAM}
  7. To add some more complexity to this issue, I am integrating this report into an AppFuse/Spring framework. To achieve this integration I am thinking I will need to create a custom Spring JasperReportsPdfView which will do the manual merging of the pdf file into an output stream to be returned to the browser for download. Has anyone ever done anything similar? Lucian/Teodor any word on having portrait and landscape pages in PDF and other exporters is going to make it into a release of Jasper anytime soon? Thx, Rob
  8. Another way to do it is to create dummy groups and include the pages in the group Footer band. The expression would be $V{REPORT_COUNT}. You would need to size the band to approx a full page height for it to space properly.
  9. Try having the subreport implement a dummy group whose expression is $V{REPORT_COUNT} and make sure that the group is set to start a new page each time. Alternatively you could try dragging out the detail band of the subreport so that your sure it would fit on exactly 1 page. Alternatively I have done this within the master report to achieve the same effect, it all depends on the datasource(s) and how they are structured for your report.
  10. Thanks Teodor! Edit: To achieve multiple page layouts for reports I did 2 different methods.. 1. No Post Editing Was Needed: Used pure jasper, as described above: Code: 2. Post Editing Required: -e.g. To add page numbering in header. -Used iText ) wrote a program to merge the pages and manually insert page numbering on the pages. Code:Incidentally Teodor/Lucian, is this type of functionality on the horizon for jasper reports?
  11. Sorry, I was referring to the best way to align the contents of the fields so that they appear as a series of sequential lines, and these lines would be centered verticially and without missing lines in the given address space in my report. So given the space... --------------------------------------------- . .addr1 .addr2 .addr3 .addr4 .addr5 . --------------------------------------------- If I had blank values for addr2 (e.g.) I wouldn't have... --------------------------------------------- . .addr1 . .addr3 .addr4 .addr5 . --------------------------------------------- but instead have... --------------------------------------------- . .addr1 .addr3 .addr4 .addr5 . . --------------------------------------------- Now that I've implemented the address as a variable I kind of like that approach, as I can just make 1 large field and center text verticially in the field. Thx. Rob
  12. Note: I ended up creating a variable "ADDRESS" whose expression was: "\n" + (($V{FULL_NAME} == null || $V{FULL_NAME}.length() == 0)?"":($V{FULL_NAME} + "\n")) + (($F{addr1} == null || $F{addr1}.length() == 0)?"":($F{addr1} + "\n")) + (($F{addr2} == null || $F{addr2}.length() == 0)?"":($F{addr2} + "\n")) + (($F{addr3} == null || $F{addr3}.length() == 0)?"":($F{addr3} + "\n") ) + (($F{addr4} == null || $F{addr4}.length() == 0)?"":($F{addr4} + "\n")) + (($F{addr5} == null || $F{addr5}.length() == 0)?"":($F{addr5} + "\n")) The \n at start centers with the inevitable \n at end and for now I will ignore use of the .trim() Post edited by: rsilver@bfm.bm, at: 2006/10/12 17:57
  13. Hey all, Was tossing around a few ideas of how to do this, and wanted to see how others would do it. Here is the scenario... I have 5 lines for address in my database... i.e. addr1 = Suite #101 addr2 = 123 Main St. addr3 = Anytown addr4 = MyState, MyCountry addr5 = 12345 The problem is that there can be a varying number of lines used, i.e. someones address could be... addr1 = addr2 = 123 Main St. addr3 = Anytown addr4 = MyState, MyCountry addr5 = 12345 On top of this, given user error, the data is not guaranteed to be in order, so as given above, it may be addr1 that is blank, addr2 and so on. Plus I am not going to count on the user not having entered a " " into one of the fields. My goal is to account for all of these things if possible. Initially I had 5 lines, with a removeLineWhenBlank flag set on each and was calling .trim() on each field to make sure that they would be the top fields in sequence with no blank lines on a produced report. However this wasn't centering the fields in the given address window. My challenge, is how would you accomplish this? I considered using a variable, but the expression to the check for null, .trim().length() == 0, add in a n etc for each field made for an ugly expression that can't be efficient at runtime.
  14. In consideration of a modular design and ease of updates I would include the queryString in the report and just pass in a connection to a database to run the query against. (That being said, I would leave it up to lucian or teodor to comment on which is the most efficient approach for large datasets.) Doing it this way, you would take the 3 fields that you are searching by... lets use an example of students... you could search by student age, student FirstName, student last name.... So you pass to the report a parameters Hashmap containing... "STUDENT_AGE"->"15" "STUDENT_FNAME"->"Jasper" "STUDENT_LNAME->"Anon" Then your query string would look something roughly like... select * from database.table where age='$P!{STUDENT_AGE}', fname='$P!{STUDENT_FNAME}' etc. etc. Note: You would have to define these 3 parameters in your report definition. It is true you could simply return an html page containing the data organized in a table etc. and not use jasperreports at all. JasperReports brings a lot of flexibility to the process however. With Jasper you could export to CSV, HTML, PDF, XLS etc. etc. as per your needs with little changing of the code. It is all a matter of specific demands of the project.
  15. Do you mean export your report to a jpeg, or actually take a capture of the report file text and store it as a jpeg? I am not sure of an exporter which exports directly to jpeg, gif etc. But if you export to pdf, there are many ways to convert to an image file. Although pdf itself is a pretty universal format. You can always print-screen the jrxml file in a text editor of your choosing to capture that text. Hth, Robin
  16. You could write the query in a servlet and then run the query and pass the result set into the report to be used to fill the report, OR pass the connection to the database into the report and have a queryString already specified in the report for the <queryString> element to run the query for you. Either way, jasper can easily format and display the output nicely.
  17. If you create a custom data source you can pass it anything you want. You could run your SQL query in your java program then do the custom ordering and pass this list into your data source. Check out the JRBeanDataSource and other collection based data sources also.
  18. It is related to the underlying functionality of the '+' operator in java. Strings are able to be appended using the '+' even though they are objects, its an exception to the rule. To add the Double objects you have to treat each field as an object and use dot-notation in your expression fro the BALANCE_DUE field. new Double($F{grandtotal}.doubleValue() + $F{previous_due}.doubleValue() - $F{amount_paid}.doubleValue()) Notice that there is no ";" at the end of the expression. Now if one of the above objects is null, a null ptr expression would occur. To avoid this you have to modify the expression as follows... new Double( $F{grandtotal}==null?0.0:$F{grandtotal}.doubleValue() + $F{previous_due}==null?0.0:$F{previous_due}.doubleValue() - $F{amount_paid}==null?0.0:$F{amount_paid}.doubleValue()) Now there is a check to use 0.0 if the object is null. This depends on your data source etc. of course, if the object could be null. hth, Robin
  19. Can you list the expression in the field along with the exception it throws please? Robin
  20. Is this possible? I have seen on the forumns that people were unable to do it unless they used a tool in iText to merge the pages, but with page numbering this really isn't a good way to do it. My context is that my report is of a known format... Page 1 : (Portrait) covering letter Page 2 : (Portrait) summary page (user details summary, not data summary) Page 3, 4, etc: (Portrait) "Dynamic data in detail section Page n: (Landscape) Final summary page, in landscape (this page has to be in landscape, will not fit in portrait in asthetic fashion). Has a chart or two and some images etc. I am hoping that there is an easy way to have the required pages be in alternating orientations without having to use an external tool. The report is integrated into a website using a hibernate datasource and I am hoping to avoid having any overhead or extra work incurred outside the report (i.e. needing to use iText to merge documents etc) Any comments on this issue are appreciated (including the best workarounds possible should it not be possible). Thx, Rob
  21. CSV Exporting is done based upon a strict algorithm. Using features like page headers etc. are not really recommended when exporting to CSV. A good article to outline some best practices for CSV exporting is... http://jasperforge.org/sf/wiki/do/viewPage/projects.jasperreports/wiki/FAQ9 hth, Robin
  22. You can also over-lay two fields on top of each other with the same expression and format them accordingly... then modify the printWhen expression to suit your needs.
  23. You can also over-lay two fields on top of each other with the same expression and format them accordingly... then modify the printWhen expression to suit your needs.
  24. How doesn't it work? Are there errors being thrown during export, or is the layout not what you expect? You should always keep in mind when designing your reports is that there are certain report designs and layouts that are best suited depending on the output destination. i.e. a CSV output file has very strict rules about how you should place elements in your report in order for it to be interpreted as fields properly. Anyways, please elaborate on how your report is failing in html mode and we can try to work through it. Thx, Rob
×
×
  • Create New...