Jump to content

Dynamic summary


sparacello

Recommended Posts

 Hi, 

I'm bulding a very huge report.  about 700pages and customer ask to have, at the end of the report a summary which shop page number of different section.

It seems to be a not-so-strange request but I can't find this feature on jasper iReport (which I started to use today!).

What I have to do? 

I need something like

TITLE1

   Subtitle

    data data data data

    data data data data

     [...]

    data data data data

TITLE2

   Subtitle

    data data data data

    data data data data

     [...]

    data data data data

TITLE3

   Subtitle

    data data data data

    data data data data

     [...]

    data data data data


SUMMARY

TITLE1 pag 1

TITLE2 pag 350

TITLE3 pag 550

 

Link to comment
Share on other sites

  • Replies 10
  • Created
  • Last Reply

Top Posters In This Topic

I suppose it's considerate that they expect the table of contents to be at the end of the document...it shows an understanding of how data is processed most easily, although realistically a "summary" table of contents is not as standar or usable as one at the beginning.  If you're exporting to PDF, I think I have the solution for you, and it will be better than what they're requesting: when you get to a new section that should appear in your "summary", create a HYPERLINK on your group header (or whatever it is that signals the beginning of that interesting section/subsection.  If you do it as I outline below, your PDF will end up with "bookmarks", which is essentially a hyperlinked table of contents that you can hide or view from anywhere in the document, rather than having to skip to the beginning or end.

Right click on a field (first text field in group header, for example) and select "Hyperlink".  Set the "Anchor Name Expression" to what you want to appear in the bookmark list, $F{BRANCH_DESCRIPTION}, for example.  Bookmark Level 1 is the topmost level of bookmark, but you can also use level 2, 3, etc. if you have subsections.  For "Hyperlink target" use "Self" and for Hyperlink type, put "None" (we're not creating a hyperlink that takes you clickm on this field and takes you somewhere else or executes a drill-down report).  You can fill in a tooltip expression, but for a bookmark, I think you'd usually leave this blank as well.

Caution: if you repeat a group header at the top of every page, don't give it a hyperlink if you really only wan the bookmark to be for the START of the new group.  Instead, create TWO fields in the group header that overlap and have a mutually exclusive condition.  For example, you could have one version of the text have a Print When Expression of $V{GroupName_COUNT)==0 and make that be the version with the hyperlink, while the other, overlapping text field could have a Print When Expression of $V{GroupName_COUNT)>0 with no hyperlink defined (the second text field could also include something like + “ (continued)” in the Text Field Expression if you like).  Also, you can’t add a hyperlink to a Static Text element, so use a Text Field element, even if your text is actually static (if you need a hyperlink, that is).

I think this technique is really only useful lif you're exporting to PDF and you expect that the reader is going to be reading the document online rather than a printed copy, but in that situation, PDF bookmarks are a VERY effective tool.  If you ask your user whether they'll be reading online or hardcopy, they'll probably  do the typical user thing and say that they need it to work EITHER way.  If they actually see and try out a version with the PDF bookmarks, I bet they'll love it.

Good luck,

Carl

Link to comment
Share on other sites

Hi Carl, 

THANK YOU so MUCH

your reply perfectly meet my requirement.. at leat I understood it yesterday.  :( :(

Talking with customer I got an example on what they means.

So I have a recordset with lot of data (700 pages) made in this say

Division1,Society1,orders1

Division1,Society1,orders2

Division1,Society1,orders3

Division1,Society2,orders1

Division1,Society2,orders2

Division1,Society3,orders3

 

Division2,Society1,orders1

Division2,Society1,orders2

Division2,Society2,orders3

the expected report want to group this with page number. In this way

  • Division1                  pag1
    •    society1    pag1
    •    society2    pag50
    •    society3    pag150
  • Division2                  pag220
    •    society1    pag220
    •    society2    pag350

 

it is possibile to create these hyperlink based on these grouping way?

Link to comment
Share on other sites

You can definitely do the subdivisions like that.  I confess that I've never tried to output the page number as part of that table of contents, because the whole idea is that you don't CARE what page it's on when you're looking at the bookmarks...you just find what you like and click on it, and you're there!  I've enclosed a document that I just threw together that is a very crude example...I'm returning transactions sorted by the date they posted, and I've created a separate group for the year, the month, and the day of the month, and I've made each of those groups have their own bookmark level (1 for year, 2 for month, 3 for day).  Yes, it would look nicer if I translated the month number to a name, etc., but at least you can see the functionality.

I made a half-hearted attempt to include a page number in the bookmarks, with limited success.  I don't usually include them...just the topic description itself.  Open the document and click on the bookmarks icon on the left if the bookmarks aren't already opened when you open the document.

Carl

P.S.: first I forgot to attach the pdf, then I accidentally attached the jrxml instead!  Third time's a charm.

Code:



Post Edited by cbarlow3 at 01/14/2011 16:07



Post Edited by cbarlow3 at 01/14/2011 16:08
Link to comment
Share on other sites

  • 1 month later...

Finally I completed main report and start facing the last challenge. Table of content.

Bookmarks is very interesting and I'll impement it without page number. But my problem is that customer want to print it (damn, 782 pages) and so he definitely need something like one I put as attachment.

There is a way?

 

Thank you for everything

Link to comment
Share on other sites

I hate to suggest it, but if they're going to insist that you PRINT that many pages, can I assume that this isn't a daily report that runs automatically?  If YOU are going to be running this report and distributing the output on a rare basis rather than THEM running the report on a frequent schedule and printing it out, then maybe the best thing to do is to generate the report, export to Word, and then insert a Word Table of Contents.  I think for that to work automatically, you have to use distinct fonts for the various levels of headers that you want the table of contents to automatically recognize as levels that should appear in the automatic table of contents.

It might take a little massaging.

Your question just made me remember how much work some of these things are that we take for granted:  Page x of y, a table of contents at the beginning of the document.  It's kind of crazy when you think of all the calculation and rendering that has to occur.  When you realize that the FONT SIZE affects what page things fall on, the margins affect it, the way word wrap is conducted, including if/where words are broken with automatically inserted hyphens, why even the length of the table of contents affects the page numbers that follow it, which in turn affects the page numbers that appear on the table of contents, etc.  It makes my head hurt.

It reminds me of when I used to have to create batch export files (fixed length format) from time to time.  Most of the specifications had some kind of fixed record length, a header record that indicated who the file was from, the purpose of the file, the date, etc., a varying number of detail records, and a file trailer record that had some totals.  If the recipient of the file found that the trailer record was missing or that the totals didn't agree with internal totals they calcualted while running through the detail records, they knew that there was a problem with the file.

But occasionally a vendor would decide that it would really be more convenient for them if the total information appeared in the file HEADER!  Well, I used to just hate that.  You want to just spool the file out to disk as you build it, but no...instead you have to go back and finish your file header AFTER you're done creating your detail records.  All this stuff that the reporting tools and PDF renderers, etc. have to do is so much more complicated and circular than that minor inconvenience of years ago!

Sorry I couldn't think of any iReport magic to help out.

Carl

Link to comment
Share on other sites

  • 2 months later...

 Yes, but I had to ask to developer team to write a java class which do this for me. 

Few methods and you have to call class method for each section passing it current page and hierarchy level then, at the end, call another method which just build the content table with data you provided it while writing report

Link to comment
Share on other sites

How you export to Word depends on how you're using JasperReports in the first place:  if you're using JasperReports Server to run your reports, then when you see a report result display, you should also have little icons display that let you export to Excel, Word, PDF, etc.

If you are running a .jasper file from within a Java program, then after your line that looks similar to this:

      JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, jasperParameter, connection);

you would have a set of lines that looks like this:


      JRPdfExporter export = new JRPdfExporter();
      export.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
      export.setParameter(JRExporterParameter.OUTPUT_FILE_NAME,"output.pdf");


--except that these lines are for PDF export.  I know there's a JRDocxExporter, and it probably works similarly, but I haven't used it yet from within a Java program.

As for preview mode in iReport, I'm on version 3.7 Professional, so it may look different depending on what version you're using, but my main menu bar has an option for Preview, and one of the many selections there is "MS Word (DOCX) Preview".  If you have Word 2007 or later installed and that preview mode doesn't automatically export to Word when you run a preview of a report, the export configurations are normally reached by going into "Tools | Options | iReport | Export Options", but I confess that I only see settings for "Common, PDF, HTML/XHTML, Excel, CSV, Text, and Text (iReport)".  Not sure why I don't see an option for Word.  I seem to remember during setup that there was a specific screen for mapping the export function to a program, but I don't seem to see it anywhere in my notes or in the menus.

Carl

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...