You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by Ryan Ackley <sa...@cfl.rr.com> on 2003/11/12 16:15:53 UTC

HWPF

Good news everyone, I am able to successfully edit a simple Word document
with HWPF. I will commit and post some sample code tonight. Right now it
only works on the simplest of files but over the next few
days/weeks/months/years, I will be adding features and making it more
robust.

Unfortunately, at this moment I am toiling at my day job because I had to
get to work because I was already late. I want to be home working on HWPF!

Ryan


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-dev-help@jakarta.apache.org


Re: HWPF example

Posted by Rainer Klute <ra...@epost.de>.
On Wed, 12 Nov 2003 22:36:21 -0500 "Ryan Ackley" <sa...@cfl.rr.com> wrote:
> If anyone is interested, here is some example code that will insert some
> Bold, Italic, All Upper Case text to the beginning of a Word document. It
> only seems to work with all ASCII Word files. I am trying to fix the problem
> it has with unicode. This code may take some tweaking I just copied and
> pasted the main function from HWPFDocument and added some imports for
> people's convenience.
> ...

Hi Ryan,

I suggest that you commit your sample to the CVS tree. We have a directory src/examples/src/org/apache/poi with subdirectories hpsf and hssf. There should still be room for an hwpf directory.

Best regards
Rainer Klute

                           Rainer Klute IT-Consulting GmbH
  Dipl.-Inform.
  Rainer Klute             E-Mail:  klute@rainer-klute.de
  Körner Grund 24          Telefon: +49 172 2324824
D-44143 Dortmund           Telefax: +49 231 5349423

Re: HWPF example

Posted by Ryan Ackley <sa...@cfl.rr.com>.
Fixed the unicode problem this morning. Not sure if it was unicode specific
though. The previous example is now safe to try on documents that use
character encoding other than Cp1252. Let me know how it goes. I have to get
to my job.

Ryan

----- Original Message ----- 
From: "Serge Huber" <sh...@jahia.com>
To: "POI Developers List" <po...@jakarta.apache.org>
Sent: Thursday, November 13, 2003 7:48 AM
Subject: Re: HWPF example


>
> Hey looks great ! I like the Range interface, looks powerful and simple.
> Looking forward to Unicode support though :)
>
> Regards,
>    Serge Huber.
>
> At 04:36 AM 11/13/2003, you wrote:
> >If anyone is interested, here is some example code that will insert some
> >Bold, Italic, All Upper Case text to the beginning of a Word document. It
> >only seems to work with all ASCII Word files. I am trying to fix the
problem
> >it has with unicode. This code may take some tweaking I just copied and
> >pasted the main function from HWPFDocument and added some imports for
> >people's convenience.
> >
> >
> >
> >package test;
> >
> >import org.apache.poi.hwpf.HWPFDocument;
> >import org.apache.poi.hwpf.Range;
> >
> >import org.apache.poi.hwpf.usermodel.CharacterRun;
> >import java.io.*;
> >
> >public class Test
> >{
> >/**
> >    * Takes two arguments, 1) name of the Word file to read in 2)
location to
> >    * write it out at.
> >    * @param args
> >    */
> >   public static void main(String[] args)
> >   {
> >
> >     try
> >     {
> >       HWPFDocument doc = new HWPFDocument(new FileInputStream(args[0]));
> >       CharacterRun run = new CharacterRun();
> >       run.setBold(true);
> >       run.setItalic(true);
> >       run.setCapitalized(true);
> >
> >       Range range = doc.getRange();
> >       range.insertBefore("Hello World!!! HAHAHAHAHA I DID IT!!!", run);
> >
> >       OutputStream out = new FileOutputStream(args[1]);
> >       doc.write(out);
> >
> >       out.flush();
> >       out.close();
> >
> >
> >     }
> >     catch (Throwable t)
> >     {
> >       t.printStackTrace();
> >     }
> >   }
> >}
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: poi-dev-help@jakarta.apache.org
>
> - -- --- -----=[ shuber2 at jahia dot com ]=---- --- -- -
> www.jahia.org : A collaborative source CMS and Portal Server
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: poi-dev-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-dev-help@jakarta.apache.org


Re: HWPF example

Posted by Serge Huber <sh...@jahia.com>.
Hey looks great ! I like the Range interface, looks powerful and simple.
Looking forward to Unicode support though :)

Regards,
   Serge Huber.

At 04:36 AM 11/13/2003, you wrote:
>If anyone is interested, here is some example code that will insert some
>Bold, Italic, All Upper Case text to the beginning of a Word document. It
>only seems to work with all ASCII Word files. I am trying to fix the problem
>it has with unicode. This code may take some tweaking I just copied and
>pasted the main function from HWPFDocument and added some imports for
>people's convenience.
>
>
>
>package test;
>
>import org.apache.poi.hwpf.HWPFDocument;
>import org.apache.poi.hwpf.Range;
>
>import org.apache.poi.hwpf.usermodel.CharacterRun;
>import java.io.*;
>
>public class Test
>{
>/**
>    * Takes two arguments, 1) name of the Word file to read in 2) location to
>    * write it out at.
>    * @param args
>    */
>   public static void main(String[] args)
>   {
>
>     try
>     {
>       HWPFDocument doc = new HWPFDocument(new FileInputStream(args[0]));
>       CharacterRun run = new CharacterRun();
>       run.setBold(true);
>       run.setItalic(true);
>       run.setCapitalized(true);
>
>       Range range = doc.getRange();
>       range.insertBefore("Hello World!!! HAHAHAHAHA I DID IT!!!", run);
>
>       OutputStream out = new FileOutputStream(args[1]);
>       doc.write(out);
>
>       out.flush();
>       out.close();
>
>
>     }
>     catch (Throwable t)
>     {
>       t.printStackTrace();
>     }
>   }
>}
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: poi-dev-help@jakarta.apache.org

- -- --- -----=[ shuber2 at jahia dot com ]=---- --- -- -
www.jahia.org : A collaborative source CMS and Portal Server 



---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-dev-help@jakarta.apache.org


HWPF example

Posted by Ryan Ackley <sa...@cfl.rr.com>.
If anyone is interested, here is some example code that will insert some
Bold, Italic, All Upper Case text to the beginning of a Word document. It
only seems to work with all ASCII Word files. I am trying to fix the problem
it has with unicode. This code may take some tweaking I just copied and
pasted the main function from HWPFDocument and added some imports for
people's convenience.



package test;

import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.Range;

import org.apache.poi.hwpf.usermodel.CharacterRun;
import java.io.*;

public class Test
{
/**
   * Takes two arguments, 1) name of the Word file to read in 2) location to
   * write it out at.
   * @param args
   */
  public static void main(String[] args)
  {

    try
    {
      HWPFDocument doc = new HWPFDocument(new FileInputStream(args[0]));
      CharacterRun run = new CharacterRun();
      run.setBold(true);
      run.setItalic(true);
      run.setCapitalized(true);

      Range range = doc.getRange();
      range.insertBefore("Hello World!!! HAHAHAHAHA I DID IT!!!", run);

      OutputStream out = new FileOutputStream(args[1]);
      doc.write(out);

      out.flush();
      out.close();


    }
    catch (Throwable t)
    {
      t.printStackTrace();
    }
  }
}


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-dev-help@jakarta.apache.org


Re: HWPF

Posted by Avik Sengupta <Av...@itellix.com>.
Cool!

On Wed, 2003-11-12 at 20:45, Ryan Ackley wrote:
> Good news everyone, I am able to successfully edit a simple Word document
> with HWPF. I will commit and post some sample code tonight. Right now it
> only works on the simplest of files but over the next few
> days/weeks/months/years, I will be adding features and making it more
> robust.
> 
> Unfortunately, at this moment I am toiling at my day job because I had to
> get to work because I was already late. I want to be home working on HWPF!
> 
> Ryan
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: poi-dev-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-dev-help@jakarta.apache.org