the apache poi API

D

dimov.vlatko

Hi,

Has anyone used the apache POI APi to construct Word documents?
I have this piece of code wich creates .doc file from data that is
extracted by the WordExtractor class from another .doc file -
Lettet.doc.


String filename = "E:\\Letter.doc";
FileInputStream fis = null;
try {
fis = new FileInputStream(filename);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
try {
HWPFDocument doc = new HWPFDocument(fis);
WordExtractor we = new WordExtractor(doc);
String wordtext = we.getText();
PrintWriter file = new PrintWriter(new BufferedWriter(new
FileWriter("E:\\NewLetter.doc")));
StringBuffer strbuf = new StringBuffer(wordtext);
strbuf.delete(0, 80);
String wordtextOut = strbuf.toString();
System.out.println(wordtextOut);
file.print(wordtextOut);
file.close();


I construct the document NewLetter.doc but the data inside it is raw
text, so which class of the POI API should I use to make some changes
in the NewLetter.doc like making the text inside BOLD or changing the
size.
Thanks
 
R

Roedy Green

I construct the document NewLetter.doc but the data inside it is raw
text, so which class of the POI API should I use to make some changes
in the NewLetter.doc like making the text inside BOLD or changing the
size.
You format by defining nested styles with HWPF then applying styles to
hunks of text. Sorry I don't know the exact classes.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top