• Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading and Writing Microsoft Documents  RSS feed

 
Mike Pederon
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I've had 2 semesters of java and am still learning things.
I want to be able to extract text from a word document and write to an excel document.
I found Apache POI, that seems to be able to do this task, but I'm not sure what exactly what I should download or how to use it, after I download.
If anyone could provide a step-by-step process I should use to be able to use the Apache POI, that would be great.
I need to know:
- what to download
- how to install and verify
- and be able to use the program I make with this POI on any computer computer, like would I have to do any special install on that computer or is it something that is included within the jar I make in the end...
Im kinda a noob so any information on how to go about how to get this to work would be excellent.

My objective is to be able to read data from a templated Word Document and organize that data into an excel document. First thing I need is a method to read in word docs and write in excel spreadsheets.

ANY help to getting the Apache POI installed and start using it to read and write Microsoft Documents would be Fantastic!
Thank you in advance for any help!
 
William P O'Sullivan
Ranch Hand
Posts: 859
Chrome IBM DB2 Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a loaded question.

What type of application?

Stand-alone java or web-app?
If web-app, what frameworks and how is it built? maven/ant etc.

As for downloading and installing, you should research which jars are needed (and any dependencies)
then add to your CLASSPATH, write a small test program and off you go.

WP
 
Mike Pederon
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I use JGrasp and downloaded the Binary Distribution and Source Distribution for POI 3.8. My main question would be how to set the CLASSPATH. It'll be a Stand-alone Java program. I need to know where to put the files I downloaded or set up the Classpath so I can import and use the methods.
 
William P O'Sullivan
Ranch Hand
Posts: 859
Chrome IBM DB2 Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know jgrasp, but I would assume if it's an IDE, you should have a wizard to start a new project.

Otherwise, textpad or notepad++ should work if you configure the java compiler (javac) and runtime (java)
requirements and CLASSPATH. Basically it has to find the poi.jar at both compilation time and runtime.

Try Eclipse, you'll like it.

WP
 
Tim Moores
Saloon Keeper
Posts: 4024
94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It doesn't matter where you put the files, they just need to be all in the CLASSPATH. The easiest way is to use the "-classpath" switch, IMO. So your command might look like:

java -classpath .;poi-3.8-20120326.jar;poi-ooxml-3.8-20120326.jar;poi-ooxml-schemas-3.8-20120326.jar;poi-scratchpad-3.8-20120326.jar MyPOIProgram

Assuming that your code is not in a package and is named MyPOIProgram. Use : instead of ; if you're on a Unix-based OS.
 
Mike Pederon
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, so I use -classpath, but is that something I use in my .java code?
or is it an external variable that I use for the java engine itself?

How would I go about implementing -classpath?
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!