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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

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




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to