Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML


 
  
 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 

 
Facing Programming Problem?
Ask Questions?, Browse Latest Questions, Question-Answer Guidelines
Java
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

Find String Values of Cell Using POI

                         

In this program we are going to find the String Values of Cell of  an excel sheet using POI3.0 API Event.

The class  org.apache.poi.hssf.record.LabelSSTRecord extends Record implements CellValueRecord interface and java.lang.Comparable
This is used  to make reference of a string  and a column value. 

The methods used in this example:

getSSTIndex():
The method is used to get the index to the string in the SSTRecord. The return type of this method is integer (index of string in the SST Table).

getString(int i):
This method is used to get the string  value from SSTRecord .

The code of the program is given below:
import java.io.*;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.poifs.filesystem.*;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.eventusermodel.*;
import org.apache.poi.hssf.record.*;
import org.apache.poi.hssf.dev.EFHSSF;
public class FindStringCellsValues implements HSSFListener
{
   public static void main(String[] argsthrows IOException
    {
       FileInputStream fin = new FileInputStream(args[0]);
     
        POIFSFileSystem poifs = new POIFSFileSystem(fin);
        InputStream din = poifs.createDocumentInputStream
(
"Workbook");
          HSSFRequest req = new HSSFRequest();
           req.addListenerForAllRecords
(
new FindStringCellsValues());
           HSSFEventFactory factory = new HSSFEventFactory();
            factory.processEvents(req, din);
            fin.close();
             din.close();
        System.out.println("STOP");
    }
  SSTRecord sstrecord;
  public void processRecord(Record record)
    {
        switch (record.getSid()) {
            case SSTRecord.sid:
                sstrecord = (SSTRecordrecord;
                for (int k = 0; k < sstrecord.
getNumUniqueStrings
(); k++)
                {
                    System.out.println("String 
table value " 
+ k + " = " + sstrecord.getString(k));
                }
        System.out.println("\n\n");
                break;
        
            case LabelSSTRecord.sid:
                LabelSSTRecord lrecord = (LabelSSTRecordrecord;
                System.out.println("String cell found with value \t"
                        + sstrecord.getString(lrecord.getSSTIndex()));
                break;
            }
   }    
}

The output of the program is given below:

C:\POI3.0\exmples\execl>javac FindStringCellsValues.java

C:\POI3.0\exmples\execl>java FindStringCellsValues example.xls
String table value 0 = Name Of Example
String table value 1 = Status
String table value 2 = coding is completed
String table value 3 = compressedUnicode.java
String table value 4 = EventAPIsExample.java
String table value 5 = FindNameOfSheet.java
String table value 6 = FindRowAtColumn.java
String table value 7 = FindStringCellsValues.java
String table value 8 = FindValuesRowAtColumn.java
String table value 9 = setDataFormat.java
String table value 10 = setDataFormatForFullList.java
String table value 11 = setNameUnicodeDataFormat.java
String table value 12 = setSheetNameUnicodeDataFormat.java
String table value 13 = setUnicodeDataFormat.java
String table value 14 = TypeOfSheet.java
String table value 15 = TypeOfWorkBook.java



String cell found with value    Name Of Example
String cell found with value    Status
String cell found with value    compressedUnicode.java
String cell found with value    coding is completed
String cell found with value    EventAPIsExample.java
String cell found with value    coding is completed
String cell found with value    FindNameOfSheet.java
String cell found with value    coding is completed
String cell found with value    FindRowAtColumn.java
String cell found with value    coding is completed
String cell found with value    FindStringCellsValues.java
String cell found with value    coding is completed
String cell found with value    FindValuesRowAtColumn.java
String cell found with value    coding is completed
String cell found with value    setDataFormat.java
String cell found with value    coding is completed
String cell found with value    setDataFormatForFullList.java
String cell found with value    coding is completed
String cell found with value    setNameUnicodeDataFormat.java
String cell found with value    coding is completed
String cell found with value    setSheetNameUnicodeDataFormat.java
String cell found with value    coding is completed
String cell found with value    setUnicodeDataFormat.java
String cell found with value    coding is completed
String cell found with value    TypeOfSheet.java
String cell found with value    coding is completed
String cell found with value    TypeOfWorkBook.java
String cell found with value    coding is completed
STOP

Download this example.

                         

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Latest Searches:
convert radian to grad
write to text file
axis web sercice clien
breakР°Р?????Р°Р
read ascii
creating table using b
json lib/components/co
json lib/components/co
Struts 2
ResultSet.CONCUR_UPDAT
HOW TO counting billio
login eample code usin
javascript statements
date format
upload file to server
how to use zx in jsp
working with combobox
bean
add scrollbar in jsp
what is offset
How to get data from d
Visual Basic Date and
how to calculate age g
Scanner
using character to vie
Ajax with JSP
Subversion Eclipse Plu
ajax auto complete
packagesand interfaces
bean:write
use of input attribute
ifAnyGranted tag in j
add tag examples in st
download a webpage usi
JavaandcoldfusionTutor
fileupload jsf
acknowledging browser
socket program usign s
Building a Simple EJB
downloadawebpageusings
Photoshop Effects Vale
applet struts
json lib//componen...]
meaning of linear sea
how we can write a jav
easygraphics
json lib//componen...]
oracle9i
networking programs
photo upload using tom
.net
Linux Caixa Mรà¸??à¸
How do you sort an arr
JVM vs Interpretor
username and password
selecting option value
Application Server
retrive image from dat
validate user input in
stopping
example of Jtext area
populate drop down fro
Combattons la programm
Flash Tutorial : Parti
midlet inbox example
DOM
data structures
dbcp
Photoshop Text Effect
hide combo box jsp
to insert an element
to insert an element i
deployment java progra
remote method invocati
Hidden Form Fields
how to iterate a linke
cancel button in ?Jsp
encapsulation
call ????????????????Â
JSF data table
Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.