Reporting tool in Java

Discussion in 'Java' started by Jujo, Feb 7, 2007.

  1. Jujo

    Jujo Guest

    Hello.

    Does anyone know a reporting tool in Java, which can load a template
    (previously made in Word or other word processor, for example) and fill in
    defined fields ? (inside the report are some sophisticated features which
    cannot be achieved with iReport + JasperReport)

    Regards,
    Jujo
    Jujo, Feb 7, 2007
    #1
    1. Advertising

  2. Jujo

    Stefan Ram Guest

    "Jujo" <> writes:
    >Does anyone know a reporting tool in Java, which can load a
    >template (previously made in Word or other word processor, for
    >example) and fill in defined fields ? (inside the report are
    >some sophisticated features which cannot be achieved with
    >iReport + JasperReport)


    With Microsoft® Word installed, one can use a COM brigde to
    open Microsoft® Word and control it from within a Java
    program to instantiate and print the template.

    This way, one does not have to write Java code to parse and
    interpret Microsoft® Word files.

    Otherwise, in order to instantiate a custom template (not a
    Microsoft® Word template) in Java one does not need a library
    for simple cases.

    public class Main
    {
    public static java.lang.String replace
    ( final java.lang.String template,
    final java.util.Map<java.lang.String,java.lang.String> map )
    { final java.lang.StringBuilder list =
    new java.lang.StringBuilder( "\\$(" );
    for( final java.lang.String key: map.keySet() )
    { list.append( key ); list.append( "|" ); }
    list.append( "[^\\s\\S])" );
    java.util.regex.Pattern pattern =
    java.util.regex.Pattern.compile( list.toString() );
    java.util.regex.Matcher matcher = pattern.matcher( template );
    final java.lang.StringBuffer stringBuffer = new java.lang.StringBuffer();
    while( matcher.find() )
    { final java.lang.String string = matcher.group( 1 );
    matcher.appendReplacement
    ( stringBuffer, map.get( string )); }
    matcher.appendTail( stringBuffer );
    return stringBuffer.toString(); }

    public static void main( final java.lang.String[] args )
    { final java.util.Map<java.lang.String,java.lang.String> map =
    new java.util.HashMap<java.lang.String,java.lang.String>();
    map.put( "user", "Mary" );
    map.put( "name", "Patricia" );
    java.lang.System.out.println
    ( replace( "Hello $user, my name is $name.", map ) ); }}
    Stefan Ram, Feb 7, 2007
    #2
    1. Advertising

  3. Jujo

    Jujo Guest

    Well, I`ll be running my application on AIX server, so there won`t be any
    Microsoft in it :)
    Any other ideas?

    jujo

    "Stefan Ram" <-berlin.de> wrote in message
    news:-berlin.de...
    > "Jujo" <> writes:
    >>Does anyone know a reporting tool in Java, which can load a
    >>template (previously made in Word or other word processor, for
    >>example) and fill in defined fields ? (inside the report are
    >>some sophisticated features which cannot be achieved with
    >>iReport + JasperReport)

    >
    > With Microsoft® Word installed, one can use a COM brigde to
    > open Microsoft® Word and control it from within a Java
    > program to instantiate and print the template.
    >
    > This way, one does not have to write Java code to parse and
    > interpret Microsoft® Word files.
    >
    > Otherwise, in order to instantiate a custom template (not a
    > Microsoft® Word template) in Java one does not need a library
    > for simple cases.
    >
    > public class Main
    > {
    > public static java.lang.String replace
    > ( final java.lang.String template,
    > final java.util.Map<java.lang.String,java.lang.String> map )
    > { final java.lang.StringBuilder list =
    > new java.lang.StringBuilder( "\\$(" );
    > for( final java.lang.String key: map.keySet() )
    > { list.append( key ); list.append( "|" ); }
    > list.append( "[^\\s\\S])" );
    > java.util.regex.Pattern pattern =
    > java.util.regex.Pattern.compile( list.toString() );
    > java.util.regex.Matcher matcher = pattern.matcher( template );
    > final java.lang.StringBuffer stringBuffer = new
    > java.lang.StringBuffer();
    > while( matcher.find() )
    > { final java.lang.String string = matcher.group( 1 );
    > matcher.appendReplacement
    > ( stringBuffer, map.get( string )); }
    > matcher.appendTail( stringBuffer );
    > return stringBuffer.toString(); }
    >
    > public static void main( final java.lang.String[] args )
    > { final java.util.Map<java.lang.String,java.lang.String> map =
    > new java.util.HashMap<java.lang.String,java.lang.String>();
    > map.put( "user", "Mary" );
    > map.put( "name", "Patricia" );
    > java.lang.System.out.println
    > ( replace( "Hello $user, my name is $name.", map ) ); }}
    >
    >
    Jujo, Feb 7, 2007
    #3
  4. Jujo

    Lew Guest

    Please do not top-post.
    (Posting order corrected.)

    "Jujo" <> writes:
    >>> Does anyone know a reporting tool in Java, which can load a
    >>> template (previously made in Word or other word processor, for
    >>> example) and fill in defined fields ? (inside the report are
    >>> some sophisticated features which cannot be achieved with
    >>> iReport + JasperReport)


    "Stefan Ram" <-berlin.de> wrote ...
    >> With Microsoft® Word installed, one can use a COM brigde to
    >> open Microsoft® Word and control it from within a Java
    >> program to instantiate and print the template.


    Jujo wrote:
    > Well, I`ll be running my application on AIX server, so there won`t be any
    > Microsoft in it :)
    > Any other ideas?


    So how are you going to use MS Word to generate the templates? ("... template
    .... previously made in Word ...")

    Stefan showed you another way. You could also use OpenOffice instead of Word.
    You could also use the iText library directly.

    - Lew
    Lew, Feb 7, 2007
    #4
  5. Jujo

    Jujo Guest

    "Lew" <> wrote in message
    news:...
    > Please do not top-post.
    > (Posting order corrected.)
    >
    > "Jujo" <> writes:
    >>>> Does anyone know a reporting tool in Java, which can load a
    >>>> template (previously made in Word or other word processor, for
    >>>> example) and fill in defined fields ? (inside the report are
    >>>> some sophisticated features which cannot be achieved with
    >>>> iReport + JasperReport)

    >
    > "Stefan Ram" <-berlin.de> wrote ...
    >>> With Microsoft® Word installed, one can use a COM brigde to
    >>> open Microsoft® Word and control it from within a Java
    >>> program to instantiate and print the template.

    >
    > Jujo wrote:
    >> Well, I`ll be running my application on AIX server, so there won`t be any
    >> Microsoft in it :)
    >> Any other ideas?

    >
    > So how are you going to use MS Word to generate the templates? ("...
    > template ... previously made in Word ...")
    >
    > Stefan showed you another way. You could also use OpenOffice instead of
    > Word. You could also use the iText library directly.
    >
    > - Lew
    >


    The thing is - user wants to have reports send back to him via browser in
    *.doc format. I can generate template files on any platform - but my
    application will run in user`s enviroment on AIX server. So I need a tool
    that will (hopefully) take an input in *.doc template and fill in some
    marked fields. Am i asking for too much :) ? Google didn`t help :(

    Jujo
    Jujo, Feb 7, 2007
    #5
  6. Jujo

    Lew Guest

    Jujo wrote:
    > The thing is - user wants to have reports send back to him via browser in
    > *.doc format. I can generate template files on any platform - but my
    > application will run in user`s enviroment on AIX server. So I need a tool
    > that will (hopefully) take an input in *.doc template and fill in some
    > marked fields. Am i asking for too much :) ? Google didn`t help :(


    If the user is unwilling to consider PDF, then perhaps RTF (rich-text format)
    would be viable. It is automatically opened by MS Word as if it were of DOC
    format. It is also much less susceptible to viruses and Trojans.

    <http://itextdocs.lowagie.com/tutorial/rtf/index.html>

    If you want to convince the customer, start showing them the licensing costs
    to use MS software to manipulate the DOC format, and point out that it is not
    native to AIX. Show them the dollar cost of .doc and they might be more
    amenable to .rtf.

    - Lew
    Lew, Feb 7, 2007
    #6
  7. Jujo

    Ian Wilson Guest

    Lew wrote:
    > Jujo wrote:
    >
    >> The thing is - user wants to have reports send back to him via browser
    >> in *.doc format. I can generate template files on any platform - but
    >> my application will run in user`s enviroment on AIX server. So I need
    >> a tool that will (hopefully) take an input in *.doc template and fill
    >> in some marked fields. Am i asking for too much :) ? Google didn`t
    >> help :(

    >
    >
    > If the user is unwilling to consider PDF, then perhaps RTF (rich-text
    > format) would be viable. It is automatically opened by MS Word as if it
    > were of DOC format. It is also much less susceptible to viruses and
    > Trojans.
    >
    > <http://itextdocs.lowagie.com/tutorial/rtf/index.html>
    >
    > If you want to convince the customer, start showing them the licensing
    > costs to use MS software to manipulate the DOC format, and point out
    > that it is not native to AIX. Show them the dollar cost of .doc and they
    > might be more amenable to .rtf.
    >


    Why try to convince them? I'd write RTF into a file with a .doc suffix and
    demonstrate it opening in Word perfectly normally. I've certainly done something
    very similar and the customers were very happy with the result. Since it meets
    the stated requirements I wouldn't confuse the customer with a discussion of
    technical underpinnings of no interest to them.
    Ian Wilson, Feb 8, 2007
    #7
  8. Jujo

    Stefan Ram Guest

    Lew <> writes:
    >If the user is unwilling to consider PDF, then perhaps RTF (rich-text format)
    >would be viable. It is automatically opened by MS Word as if it were of DOC
    >format. It is also much less susceptible to viruses and Trojans.


    The following example statement shows how to write an RTF document:

    new java,io.FileWriter("example.rtf").append("{\\rtf\\ansi Hi!\par}").close();
    Stefan Ram, Feb 8, 2007
    #8
  9. Jujo

    Stefan Ram Guest

    Supersedes: <-berlin.de>

    Lew <> writes:
    >If the user is unwilling to consider PDF, then perhaps RTF (rich-text format)
    >would be viable. It is automatically opened by MS Word as if it were of DOC
    >format. It is also much less susceptible to viruses and Trojans.


    The following example statement shows how to write an RTF document:

    new java,io.FileWriter("example.rtf").append("{\\rtf\\ansi Hi!\\par}").close();
    Stefan Ram, Feb 8, 2007
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JTB WORLD
    Replies:
    2
    Views:
    2,037
    pould
    Sep 3, 2006
  2. abacnet

    Reporting tool?

    abacnet, Aug 4, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    391
    |{evin
    Aug 4, 2003
  3. Moh. Kreifeur

    Need a good java reporting tool ?

    Moh. Kreifeur, Aug 15, 2003, in forum: Java
    Replies:
    3
    Views:
    1,010
    genesisakula
    Oct 8, 2012
  4. Giulio Toffoli

    Re: Need a good Java reporting tool ?

    Giulio Toffoli, Aug 29, 2003, in forum: Java
    Replies:
    0
    Views:
    358
    Giulio Toffoli
    Aug 29, 2003
  5. Niels Dybdahl
    Replies:
    6
    Views:
    1,322
Loading...

Share This Page