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 / August 2007

Tip: Looking for answers? Try searching our database.

the apache poi API

Thread view: 
dimov.vlatko@gmail.com - 17 Aug 2007 08:07 GMT
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
Roedy Green - 18 Aug 2007 02:39 GMT
On Fri, 17 Aug 2007 07:07:58 -0000, "dimov.vlatko@gmail.com"
<dimov.vlatko@gmail.com> wrote, quoted or indirectly quoted someone
who said :

>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.
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com



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.