Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: Creating a formatted printable report

  1. #1
    Junior Member
    Join Date
    Jan 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Creating a formatted printable report

    Hi,
    I'm not entirely sure about where to post this, but it's making me nuts.

    I'm new to Java, but not to coding in general. I'm writing a program that reads Excel files, does some things under the users control, and then needs to PRINT a form.

    I've gone through the Java printing lessons, I understand how to get stuff to print. I can make lines, and boxes, and text. The problem is formatting it. As far as I can see, the only way to build a printable form is in code, which is fine if all you want is some simple text and a line or two...

    But this form itself is kind of complex, and will be several to dozens of pages (depending on how much data there is). I can't imagine how I'm going to convert it to a serials of g.drawRect and drawString commands without going completely mad in the process.

    Surely there's another way that I just don't know about? A graphical program to lay out a printable report?

    Appreciate any suggestions. I've attached a copy of the report so you can see what I mean by "kind of complex".
    Attached Images Attached Images


  2. #2
    Junior Member
    Join Date
    Jan 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Creating a formatted printable report

    i have the exact same problem, does someone know any solution to this?
    It is the same with "crystal reports" of visual studio.

  3. #3
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,621
    Thanks
    25
    Thanked 322 Times in 300 Posts

    Default Re: Creating a formatted printable report

    Well if you are reading Excel files, why not write Excel files? Depending on your Excel Library, you should be able to create an Excel file, formatted the way you like, and set the Print Specifications. I do something similar to this where I have a program that builds a 500 page printable report. My formatting and stuff is done in Excel. I simply open the Excel file afterwards and press print.

    Alternatively, if the report is patterned, you can work with the patterns to create a dynamic GUI. I'll go more indepth if you want me to.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  4. #4
    Junior Member
    Join Date
    Jan 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Creating a formatted printable report

    @aussiemcgr
    I appreciate the suggestions!

    To be honest I hadn't considered creating the report in Excel. I have a feeling the output would be just as hard to create that way. Sounds like a good idea for the next thing I have to do though.

    What I was truly hoping for, was that there was a software tool that could be used to lay out a graphics page in the same way an IDE is used to lay out a GUI.

    By dynamic GUI, are you suggesting that I (for example) draw the data elements on the screen as if they were a user interface - presumably after hiding the original interface - then print that new interface?

  5. #5
    Junior Member
    Join Date
    Jan 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Creating a formatted printable report

    Quote Originally Posted by rjtan08 View Post
    i have the exact same problem, does someone know any solution to this?
    It is the same with "crystal reports" of visual studio.
    There doesn't appear to be software to simplify this process in Java, at least not that I could find anywhere. What I'm doing is using my favorite design program (InDesign for me), setting it to show position as points (72 points/inch), and laying out the report there.

    That makes it a lot easier to get the coordinates for my draw commands, I can just click the text box or line, and read the position data from InDesign, then type it into the command.

  6. #6
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,621
    Thanks
    25
    Thanked 322 Times in 300 Posts

    Default Re: Creating a formatted printable report

    Quote Originally Posted by bradleysm View Post
    By dynamic GUI, are you suggesting that I (for example) draw the data elements on the screen as if they were a user interface - presumably after hiding the original interface - then print that new interface?
    Well, as with most things in programming, things can be made much easier with loops. I am suggesting something like a loop that will paint (or however you're doing it) the same chunk of elements however many times you tell it to. That way you only need to create one instance of the pattern, provide a buffer (space between each instance in the pattern), and tell it how many you want.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  7. #7
    Junior Member
    Join Date
    Jan 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Creating a formatted printable report

    Quote Originally Posted by aussiemcgr View Post
    Well, as with most things in programming, things can be made much easier with loops. I am suggesting something like a loop that will paint (or however you're doing it) the same chunk of elements however many times you tell it to. That way you only need to create one instance of the pattern, provide a buffer (space between each instance in the pattern), and tell it how many you want.
    Ah, yes. That's exactly what I ended up doing. Happily, the form did have a repeating section, so I only had to design it once and the header once. Some looping and a variable to keep track of how much to offset the pixels when placing the data kept everything aligned.

    It was still a lot more labor intensive than I expected, having to create the printout essentially by hand by drawing lines and boxes from pixel to pixel. I guess I'm just surprised there's no GUI designer that, when done, produces a Printable class for you. Maybe when I get my skills polished up, that'll be my first major project.


    Thanks for the suggestions
    Steve

Similar Threads

  1. How to get unix timestamp from formatted date?
    By snytkine in forum Java Theory & Questions
    Replies: 5
    Last Post: October 12th, 2010, 08:07 AM
  2. Calling Crystal Report
    By goutamdaphtari in forum Java Theory & Questions
    Replies: 0
    Last Post: July 15th, 2010, 12:02 AM
  3. JRC export report class def not found
    By vishalthakur86 in forum Java IDEs
    Replies: 0
    Last Post: November 11th, 2009, 03:19 AM
  4. Vietnamese Character Problem in JSP Report. Chinese and Thai Char OK
    By mrvora in forum JavaServer Pages: JSP & JSTL
    Replies: 7
    Last Post: October 23rd, 2009, 02:35 AM
  5. instead of printing in the client, report get printed in the server
    By jmvenkat in forum Java Theory & Questions
    Replies: 0
    Last Post: September 19th, 2009, 01:30 AM