• Post Reply Bookmark Topic Watch Topic
  • New Topic

Read the .doc file  RSS feed

 
Megan James
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could any one give some sample code to read the .doc (MS word ) file with the font style, family and size usi ng java?.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Apache POI library can do this, in particular its HWPF module. From an HWPFDocument object you can get CharacterRun objects that encapsulate the text and its formatting. Something like:
 
Megan James
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply sir. I tried to downloaded the jar file , but i got only the source code its also not compiled properly, It has some file as missing in that. could you provide the url for downloaded the jar file of open source or how can i get the complete source code.could you help me to proceed future.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On the POI site, follow the "Download" link. You may need to click through "release" and "bin" directories to get to the correct file. It should be called poi-bin-3.2-FINAL-20081019.zip, and it contains the poi-scratchpad-3.2.jar and poi-3.2.jar files that you need to add to your classpath.

What do you mean by "it's not compiled properly" - do you mean the code I posted? You need to add import statements, and of course you must have the POI jar files in your classpath.
 
Megan James
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your comments. I got the jar file and set class path.

When running the above code it shows the following error . Kindly help me to proceed future.

org.apache.poi.hpsf.IllegalPropertySetDataException: The property set claims to have a size of 16 bytes. However, it exceeds 16 bytes.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which statement is causing this exception? Does Word have any problems with this file?
 
Megan James
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The above problem was caused because of some problem in my word format. I solved it. Thanks for your Help.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!