Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2007

Tip: Looking for answers? Try searching our database.

Reporting tool in Java

Thread view: 
Jujo - 07 Feb 2007 10:22 GMT
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
Stefan Ram - 07 Feb 2007 10:35 GMT
>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 - 07 Feb 2007 17:00 GMT
Well, I`ll be running my application on AIX server, so there won`t be any
Microsoft in it :)
Any other ideas?

jujo

>>Does anyone know a reporting tool in Java, which can load a
>>template (previously made in Word or other word processor, for
[quoted text clipped - 42 lines]
>    java.lang.System.out.println
>    ( replace( "Hello $user, my name is $name.", map ) ); }}
Lew - 07 Feb 2007 18:26 GMT
Please do not top-post.
(Posting order corrected.)

>>> 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" <ram@zedat.fu-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.

> 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
Jujo - 07 Feb 2007 19:24 GMT
> Please do not top-post.
> (Posting order corrected.)
[quoted text clipped - 21 lines]
>
> - 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
Lew - 07 Feb 2007 20:54 GMT
> 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
Ian Wilson - 08 Feb 2007 10:02 GMT
>> 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
[quoted text clipped - 14 lines]
> 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.
Stefan Ram - 08 Feb 2007 10:06 GMT
>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 - 08 Feb 2007 11:20 GMT
Supersedes: <RTF-20070208110234@ram.dialup.fu-berlin.de>

>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();


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.