• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Reading and Writing Microsoft Documents

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 859
IBM DB2 Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
IBM DB2 Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 7645
178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Check out this FAQ entry https://coderanch.com/how-to/java/HowToSetTheClasspath
For a little more detailed information http://docs.oracle.com/javase/tutorial/essential/environment/paths.html
 
reply
    Bookmark Topic Watch Topic
  • New Topic