Reporting tool in Java  
Author Message
Jujo





PostPosted: 2007-2-7 18:22:00 Top

java-programmer, Reporting tool in Java 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


 
ram





PostPosted: 2007-2-7 18:35:00 Top

java-programmer >> Reporting tool in Java "Jujo" <email***@***.com> 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





PostPosted: 2007-2-8 1:01:00 Top

java-programmer >> Reporting tool in Java 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" <email***@***.com> wrote in message
news:email***@***.com...
> "Jujo" <email***@***.com> 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 ) ); }}
>
>


 
 
Lew





PostPosted: 2007-2-8 2:27:00 Top

java-programmer >> Reporting tool in Java Please do not top-post.
(Posting order corrected.)

"Jujo" <email***@***.com> 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" <email***@***.com> 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
 
 
Jujo





PostPosted: 2007-2-8 3:24:00 Top

java-programmer >> Reporting tool in Java "Lew" <email***@***.com> wrote in message
news:email***@***.com...
> Please do not top-post.
> (Posting order corrected.)
>
> "Jujo" <email***@***.com> 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" <email***@***.com> 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


 
 
Lew





PostPosted: 2007-2-8 4:54:00 Top

java-programmer >> Reporting tool in Java 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
 
 
Ian Wilson





PostPosted: 2007-2-8 18:03:00 Top

java-programmer >> Reporting tool in Java 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.
 
 
ram





PostPosted: 2007-2-8 18:06:00 Top

java-programmer >> Reporting tool in Java Lew <email***@***.com> 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();

 
 
ram





PostPosted: 2007-2-8 19:21:00 Top

java-programmer >> Reporting tool in Java Supersedes: <email***@***.com>

Lew <email***@***.com> 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();