• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to use poi?  RSS feed

 
Ramaswamy Narayanan
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello friends

i have a doubt regarding to use the poi in java.
i have some example programs.
but i don't know the required packages for poi.
what my question is org.apache.poi.hssf.usermodel package is in which version of java.
is tomcat software is required to run the poi programs?
if not, in which version of java i can run the poi programs?

i need a immediate reply.
please help me.
thank you.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

what my question is org.apache.poi.hssf.usermodel package is in which version of java

Its not in any version of Java, since its a piece of "third party" software and entirely unconnected with the Java Language Specification.


is tomcat software is required to run the poi programs?

No. Tomcat is a servlet container. Servlets are not required to access MS file formats


if not, in which version of java i can run the poi programs?

The documentation can tell you that.
 
Luke Shannon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have used POI to extract content from MS files.

This page contains a list of jars you need to include along with POI.

http://jakarta.apache.org/poi/howtobuild.html

As previously meantioned Tomcat is not required. I am not sure the minimum version of Java required. If you click around the site a little you should find that out.

The system I am working with uses java 1.4.1

Look around carefully for others that have already built classes that do what you need before you start coding. In my case I was able to find some code that got me more than half way there (a power point content extraction).

Hope this helps,

Luke
 
Ramaswamy Narayanan
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai friends
thank u for your immediate reply.
i have got an idea to execute poi while i was browsing regarding that.
but i have another problem with that.
the steps to work with poi are

1.download "poi-bin-2.5.1-final-20040804.zip"
file
2.extract it to the folder say
c:\poi-bin-2.5.1-final-20040804
3. and then simply add to the classpath..
"c:\poi-bin-2.5.1-final-20040804\poi-2.5.1-final-20040804.jar"

the problem is, after the classpath is set, the 'java'(command to run the program) is not executed. it gives the exception as
Exception in thread "main" java.lang.NoClassDefFoundError:
but the program is compiled successfully.
i need immediate help.
please help me.
thank you
bye
narayanan
 
Nigel Browne
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In order to be of help to you, we will need a bit more information. What class are you trying to run? Please use code tags when posting code and also writing that your request for help is urgent doesn't mean that people will respond to you quicker. Answers to well structured questions tend to get answered before people spend time trying to answer vague questions.
 
Ramaswamy Narayanan
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello friends

my code is

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import org.apache.poi.hssf.usermodel.*;
import java.io.*;

public class Test extends JFrame implements ActionListener
{
Container g;
JButton next,proceed;
JComboBox one,two;
JTextField tf;
public Test()
{
g=getContentPane();
one=new JComboBox();
for(int i=0;i<5;i++)
one.addItem("a"+i);
two=new JComboBox();
for(int i=5;i<10;i++)
two.addItem("b"+i);
next=new JButton("Next");
proceed=new JButton("Proceed");
next.addActionListener(this);
proceed.addActionListener(this);
tf=new JTextField();
g.setLayout(new BorderLayout());
JPanel p1=new JPanel(new GridLayout(2,2,5,5));
p1.add(one);
p1.add(next);
p1.add(two);
p1.add(proceed);
g.add("North",tf);
g.add("Center",p1);
}
public void actionPerformed(ActionEvent ae)
{
JButton t=(JButton)ae.getSource();
if(t==next)
{
two.removeAllItems();
for(int i=5;i<10;i++)
two.addItem("a"+i);
}
else if(t==proceed)
{
HSSFWorkbook book=new HSSFWorkbook();
HSSFSheet sheet=book.createSheet();
HSSFRow row=sheet.createRow((short)0);
HSSFCell cell=row.createCell((short)0);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellValue("Welcome");
try
{
FileOutputStream fout=new FileOutputStream("myxl.xls");
book.write(fout);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
public static void main(String args[])
{
Test t1=new Test();
t1.setSize(300,300);
t1.setLocation(100,100);
t1.setVisible(true);
}
}

my problem is

if i don't set any classpath, i get error message that is, there is no HSSFWorkbook,HsSFSheet,etc.
if i set the classpath for the poi, there is no error at the time of compilation. but i get an exception at run time.
the exception is
Exception in thread "main" java.lang.NoClassDefFoundError: Test

i need an immediate reply.
please help me.
thank you
bye
narayanan
 
Nigel Browne
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ensure that your classpath includes the current directory and the directory that the class Test is in. Adding a fullstop to your classpath should do the trick
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ramaswamy I do not intend to be mean but you probably should read more on Java development before jumping to use some libraries.

--
./pope
[the_mindstorm]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!