poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sushil Khekare" <Sushil.Khek...@symphonysv.com>
Subject RE: Exception creating HWPFDocument
Date Wed, 17 May 2006 12:12:04 GMT
Use following code


docReader = new HWPFDocument(new FileInputStream(file));

			out = new StringWriter();
			
			//HWPFDocument doc = new HWPFDocument (new
FileInputStream (args[0]));
		      Range r = docReader.getRange();
		      String text=null;
		      System.out.println("Example you supplied:");
		      System.out.println("---------------------");
		      for (int x = 0; x < r.numSections(); x++)
		      {
		        Section s = r.getSection(x);
		        for (int y = 0; y < s.numParagraphs(); y++)
		        {
		          Paragraph p = s.getParagraph(y);
		          for (int z = 0; z < p.numCharacterRuns(); z++)
		          {
		            //character run
		            CharacterRun run = p.getCharacterRun(z);
		            //character run text
		            text = run.text();
		            // show us the text
		            System.out.print(text);
		          }
		          // use a new line at the paragraph break
		          System.out.println();
		        }
		      } 

-----Original Message-----
From: Gascoigne Thomas [mailto:gascoigt@AXXIA.com] 
Sent: Wednesday, May 17, 2006 5:01 PM
To: poi-user@jakarta.apache.org
Subject: Exception creating HWPFDocument

I'm just trying to start testing some poi functionality but am falling
at the first hurdle:

 

try

                {

                  InputStream in = new FileInputStream(INPUT_FILE);

                  HWPFDocument doc = new HWPFDocument(in);

                }

 

The exception is:

 

java.lang.NoSuchMethodError:
org.apache.poi.hwpf.model.TextPiece.getCP()I

            at
org.apache.poi.hwpf.model.SectionTable.CPtoFC(SectionTable.java:103)

            at
org.apache.poi.hwpf.model.SectionTable.<init>(SectionTable.java:70)

            at
org.apache.poi.hwpf.HWPFDocument.<init>(HWPFDocument.java:164)

            at
com.axxia.poi.test.POIWordDocTest.testTextExtraction(POIWordDocTest.java
:24)

            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)

            at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)

            at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)

            at java.lang.reflect.Method.invoke(Method.java:585)

            at junit.framework.TestCase.runTest(TestCase.java:154)

            at junit.framework.TestCase.runBare(TestCase.java:127)

            at junit.framework.TestResult$1.protect(TestResult.java:106)

            at
junit.framework.TestResult.runProtected(TestResult.java:124)

            at junit.framework.TestResult.run(TestResult.java:109)

            at junit.framework.TestCase.run(TestCase.java:118)

            at junit.framework.TestSuite.runTest(TestSuite.java:208)

            at junit.framework.TestSuite.run(TestSuite.java:203)

            at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe
stRunner.java:478)

            at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun
ner.java:344)

            at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu
nner.java:196)

 

 

 

Anybody know what I'm doing wrong? Would also appreciate some example
code that shows the basics of reading in a Word document and outputting
it as a (text) string. 

 

Thanks, Thomas.

 


**********************************************************************
The information in this e-mail and any attachment is confidential. 
It is intended only for the named recipient(s). If you are not a named
recipient please notify the sender immediately and do not disclose the
contents to another person or take copies. Although Axxia Systems has
taken every reasonable precaution to ensure that any attachment to this
e-mail has been checked for viruses, it is strongly recommended that you
carry out your own virus check before opening any attachment, as we
cannot accept liability for any damage sustained as a result of software
virus infection. Axxia Systems reserves the right and senders of
messages shall be taken to consent to the monitoring and recording of
e-mails addressed to axxia.com.
**********************************************************************


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


Mime
View raw message