views:

1667

answers:

3

Hi guys!

I'm thinking about including the Apache POI into my application. Main goal is to output RTF document, but DOC would be nice, too. But the documentation is not very detailed about writing a HWPFDocument and everything I found on the web isn't helpful at all.

I can read DOC files, that's working without any problem. But I really can't see how I write a document. Maybe someone can give me a short code example?

Thanks a lot!

A: 

Well,

It has been a long time since the last time I used POI. I read that the HWPFDocument is now orphaned (read on apache POI website). I would recommend using the WordML specification released by Microsoft instead.

http://en.wikipedia.org/wiki/Microsoft_Office_XML_formats

I have used this method before. The easiest way is to create a WordML template and just replace the values using XPATH

Igor Zelaya
WordML is for new OOXML formats? I'd like to have the older DOC formats too... I think with OOo and now OOXML there's not much need for a working library on DOC files. ;-)
cringe
I have used WordML since MS Office 2003.
Igor Zelaya
+1  A: 

If you want to do RTF, These are text files and they are support in all versions of Word.

you can use itext for simple stuff http://itextdocs.lowagie.com/tutorial/rtf/index.php

ro

you can export them the hard way

//-- save as example.doc -------------

{
\rtf1
\ansi
\ansicpg1252
\deff0
\deflang1033
  {\fonttbl
    {\f0
     \fswiss
     \fcharset0 Arial;
    }
  }
  {
  \*
  \generator Msftedit 5.41.21.2500;
  }
  \viewkind4
  \uc1
  \pard
  \f0
  \fs20 

  Hello World

  \par
}
l_39217_l
A: 

You can use Aspose.Words for Java. It can open and save DOC, DOCX, RTF and HTML.

romeok