Have had the chance to look around on my PC this morning and found a piece of 
test code I wrote ages ago that uses SWT to open a Word document template (.dot 
file), insert some text at various bookmarks, print the document and then save 
it away again.

If you want me to do so Christian, I am quite happy to post the code for you to 
have a look at, just let me know.

Anthony Andrews <[EMAIL PROTECTED]> wrote: Yes, but you may not like it at all.

There is a Java package called SWT (created by IBM as a part of the Eclipse 
IDE) that includes a series of classes that support OLE/COM. If you are running 
stand alone, on a Windows platform, it is possible to use these to control an 
application such as Word or Excel. There are lots of problems with this 
approach; not the least of which is that you need to discover the VBA commands 
that you must use to actually control, in your case, Word. The macro recorder 
tool that is part of Word can help but it is not the complete answer and you 
are still facing quite a learning curve. Having said that, it is possible to 
use this approach quite successfully but I must emphasise that it is not a 
quick fix.

Christian Bongiorno  wrote: The file output can be in any form I like as long 
as it can be opened by 
MS word and looks nice. It's currently output in that XMLish form. I 
can't invest a lot of time in this so staring at file formats and 
deciphering them is out.

I was looking at the API's and there is a 
HWPFDocument.write(OutputStream). I tried that and it does work; the 
output appears to be native binary doc format, which is fine with me.

So, what I can do is identify portions in the document to be updated, 
slam home new values, and save the file out.

The one trick part is that I need to generate a dynamic table in the 
doc. The columns are the same but the number of rows differ.

So basically, I could use this library to find the fields I need, update 
the string table, and save it out. I can just set sentinal values in the 
DOT as a template and key off those.

Any other ideas?

Christian
http://christian.bongiorno.org

Anthony Andrews wrote:
> Is the file to be output in the 'new' xml format that Microsoft has recently 
> adopted for Word documents? If so, then I would suggest that you visit 
> Sourceforge to see if anyone has coded a tool to parse/create this type of 
> file; I know that someone has already done so for SpreadsheetML.
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/



 
---------------------------------
Never miss an email again!
Yahoo! Toolbar alerts you the instant new Mail arrives. Check it out.

 
---------------------------------
Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.

Reply via email to