Home Answers Viewqa Java-Beginners reading excel sheet in java

 
 


rr
reading excel sheet in java
1 Answer(s)      8 months ago
Posted in : Java Beginners

can anyone tell me a proper java code to read excel sheet using poi

View Answers

September 4, 2012 at 12:21 PM


Here is a java code that reads an excel file using POI api and display the data on the console.

import java.io.*;
import java.util.*;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;

public class ReadExcel {

        public static void main(String[] args) {

                String fileName = "c:/data.xls";
                 Vector cellVectorHolder = new Vector();

                try {
                        FileInputStream myInput = new FileInputStream(fileName);

                        POIFSFileSystem myFileSystem = new POIFSFileSystem(myInput);

                        HSSFWorkbook myWorkBook = new HSSFWorkbook(myFileSystem);

                        HSSFSheet mySheet = myWorkBook.getSheetAt(0);

                        Iterator rowIter = mySheet.rowIterator();

                        while (rowIter.hasNext()) {
                                HSSFRow myRow = (HSSFRow) rowIter.next();
                                Iterator cellIter = myRow.cellIterator();
                                Vector cellStoreVector = new Vector();
                                while (cellIter.hasNext()) {
                                        HSSFCell myCell = (HSSFCell) cellIter.next();
                                        cellStoreVector.addElement(myCell);
                                }
                                cellVectorHolder.addElement(cellStoreVector);
                        }

                for (int i = 0; i < cellVectorHolder.size(); i++) {
                        Vector cellStoreVector = (Vector) cellVectorHolder.elementAt(i);
                        for (int j = 0; j < cellStoreVector.size(); j++) {
                                HSSFCell myCell = (HSSFCell) cellStoreVector.elementAt(j);
                                String stringCellValue = myCell.toString();
                                System.out.print(stringCellValue + "\t");
                        }
                        System.out.println();
                }
                 } catch (Exception e) {
                        e.printStackTrace();
                }
        }      
}









Related Pages:
reading excel sheet in java
reading excel sheet in java  can anyone tell me a proper java code to read excel sheet using poi   Here is a java code that reads an excel file using POI api and display the data on the console. import java.io.
excel sheet reading and using that data - JSP-Servlet
excel sheet reading and using that data  i have to do a read a excel sheet file of a employee record and then i have to use a employee details...://www.roseindia.net/tutorial/java/poi/readExcelFile.html http
Excel sheet image reading issue
Excel sheet image reading issue   Hello every one.I?m trying to read images from an excel sheet using OleDbDataReader. My excel file has 6... reading the record, It?s doing fine on the first 5 columns but return me
Reading the Date and time values from excel sheet
Reading the Date and time values from excel sheet  hi guys , iam trying to read excel sheet data using apache poi api .my problem is i cant read the date(dd/mm/yy) and time(hh:mm:ss) values concurrently from two different cells
Reading And Writing Excel File
reading and writing excel file   ... the excel sheet  using java . The package we need to import is : java.io.... words, we can say that it is used to read the excel file. After reading the excel
How to export data from html file to excel sheet by using java
How to export data from html file to excel sheet by using java   reading the data from Html file
Need to Remove Duplicate Records from Excel Sheet
Duplicate Records from Excel Sheet. I have one excel sheet having two fields (EmpNum, Rating) have to save in another excel sheet with unique empnum of latest empnum rating (without using sql query have to remove records from excel using java
Selecting Excel Sheet File
selecting excel sheet file       In this program we are going to select the excel sheet using java .You can create any number of  sheets and you can set selected
exporting data to excel sheet - JDBC
query in java swing program,i want to print the result about the query in excel... = wb.createSheet("Excel Sheet"); try{ Connection con = null...exporting data to excel sheet  Sir i have already send request about
Export data in excel sheet in java in struts - Struts
Export data in excel sheet in java in struts  Hello, All how can i export data in excel file i java  Hi friend, For solving the problem visit to : http://www.roseindia.net/jsp/excelfile.shtml Thanks
Reading a file from Jar JAVA
Reading a file from Jar JAVA  I have added one excel sheet into a jar file. can anybody tell me how i can read that file. actually when i am... issue with excel sheet ? or there is any other alternative. thank you
Reading a file from Jar JAVA
Reading a file from Jar JAVA  I have added one excel sheet into a jar file. can anybody tell me how i can read that file. actually when i am... issue with excel sheet ? or there is any other alternative. thank you
How to export data from jsp to excel sheet by using java
How to export data from jsp to excel sheet by using java   How to export data from jsp to excel sheet by using java
How to export data from html to excel sheet by using java
How to export data from html to excel sheet by using java   How to export data from html to excel sheet by using java
excel
excel  how to read columns values of excel file in java and store in array list in java like col1 col2 2 3 1 7 7...(); k++){ int j=i+1; HSSFSheet sheet = wb.getSheetAt(k
Printing data into Excel sheet - Java Beginners
where there is need to bring the data into "Excel Sheet" with proper format.My... database then showing it(data) to in "Excel Sheet" is it possible to do ? if yes... a Java Bean that will retrieve the data from the database and insert it into excel
Excel sheet in read only mode - WebSevices
Excel sheet in read only mode  If am opening an excel sheet(through... make changes.But that i dont want,Also i have checked the permission in excel sheet,It has both read and write permission. How can i make the excel sheet
How to get data from Excel sheet - Struts
How to get data from Excel sheet  Hi, I have an excel sheet... excel sheet and display in console first then later insert this data into database. i am using java, jsp, struts also but not using struts html tags just using
Java Program to insert a row in the same sheet of excel file
Java Program to insert a row in the same sheet of excel file  Java program to insert a row in the same sheet of excel file using poi package in java
How to export data from html file to excel sheet by using java
How to export data from html file to excel sheet by using java    How to export data from html file to excel sheet by using java
Convert the excel sheet data into oracle table through java or jsp
Convert the excel sheet data into oracle table through java or jsp  Hi Friends, Let me help this issue i am phasing Convert the excel sheet data into oracle table through java or jsp
code for attendence in excel sheet - Java Magazine
code for attendence in excel sheet  When i enter an "Empid "in an an HTML page, time of the system should save in the excel file of that Empid row(IE... the problem : Create a Excel file   Search
Create Excel Sheet Using JSP
into excel sheet using java .You can create any number of cells and rows... create excel sheet using jsp   ...();  HSSFSheet sheet = wb.createSheet("new sheet"
How to set background of an excel sheet using POI - Java Magazine
How to set background of an excel sheet using POI  Hi, i am trying to format the excel using java. How to set the background color of an excel sheet( complete sheet which includes all cells). i am using poi2.5.1. Thanks
Find Type of Excel Sheet
Find Type of Excel Sheet       In this program we are going to find type of an excel sheet...;java FindNameOfSheet example.xls New sheet named: Sheet1 New sheet named
Find Name of Excel Sheet
Find Name of Excel Sheet       In this program we are going to find the name of an excel...\exmples\execl>java FindNameOfSheet example.xls New sheet named: Sheet1 New sheet
reading data from excel file and plotting graph
reading data from excel file and plotting graph  I am doing a project using NetBeans in which i have to take input an excel file and then using the data in excel file, i have to plot graphs based on CELL ID selected. please help
How to Create New Excel Sheet Using JSP
a new  excel sheet using java .You can create any number of  new excel sheets in a excel file.  To create a excel sheet we can use third party APIs... How to create new excel sheet using jsp  
uploading and reading the excel daa
uploading and reading the excel daa  uploading the excel file not getting the data of the excel
Problem in executing macro enabled excel sheet using java
Problem in executing macro enabled excel sheet using java  Hi, I have written a java code which will read a excel sheet with macro enabled. then it will write data into sheet1 and sheet2 and it will execute a VB script
Error in reading Excel data using jsp
Error in reading Excel data using jsp  ERROR while executing bellow...; HSSFSheet sheet = wb.getSheetAt(k); int rows... j=i+1; HSSFSheet sheet = wb.getSheetAt(k); int rows
JDBC to EXcel
JDBC to EXcel  How to insert data in excel sheet from java
insert rows from Excel sheet into a database by browsing the file
insert rows from Excel sheet into a database by browsing the file  hello, I am trying to insert rows from Excel sheet into SQL database by browsing Excel file in java(JSP). I can insert rows using ODBC connetion. But using odbc
How to save excel sheet into mysql database using blob or clob
How to save excel sheet into mysql database using blob or clob  Hi All, I am new to java and i need to upload excel sheet to mysql, please suggest...) ); Please help me with the code or steps to insert a large xlsx sheet. waiting
Export data in excel sheet via Browse and upload button into mysql database
Export data in excel sheet via Browse and upload button into mysql database  how to create a Browse & Upload Buttons and then save... the Java web-application
How to export data from database to excel sheet by using java in standalone project
How to export data from database to excel sheet by using java in standalone project  How to export data from database to excel sheet by using java in standalone project
insert excel sheet into mysql as a table
insert excel sheet into mysql as a table  sir, i want to import an excel sheet into mysql5.0 database as in the table format using tomcat 6.0 by jsp
Reading an excel file into array
Reading an excel file into array  Hi, I'm trying to read in an excel file, search a column for containing key words (entered by a user) and then displaying the matching rows in a table. I'm fairly new to JavaScript. Can anyone
update excel sheet using jsp::
update excel sheet using jsp::   Hi Sir,... I have a excel sheet for employee details "i retrieve particular datas from given excel sheet and display it into another excel sheet using jsp
read data from Excel sheet
read data from Excel sheet  Hi, How to read data from an excel sheet using JSP. Thank you
how to create exce sheet using java
how to create exce sheet using java  how to create excel sheet using java
Reading excel via JSP
Reading excel via JSP   The problem is while reading cells values... the space between words and get full cell value? I am reading the value...(means while reading the cell values space should be ignored between the words
how to display data in excel sheet?
how to display data in excel sheet?  According to the user Id,some... the button and to display the data in excel sheet... there will be a button called excel download,and if we click the button data
jsp with excel sheet data uploading into database
jsp with excel sheet data uploading into database  how to upload data in excel sheet with jsp into oracle 10g database
Create Excel Sheet Using JSP
create excel sheet using jsp       In this example we create excel sheet and insert values into table of the excel sheet . In this example we use page directive
Reading and querying an Excel file in JavaScript
Reading and querying an Excel file in JavaScript  Hi, I'm trying to read in an excel file, search a column for containing key words (entered by a user) and then displaying the matching rows in a table. I'm fairly new
Zoom in Excel
can zoon in(-)  an excel sheet. By this means you can make an excel sheet... ratio of the excel sheet e.g. setZoom(3,4) means zoom the sheet as 75... can say the size of excel sheet will be shrunken by 25%.    The code
Excel Column change
Excel Column change  How to change sequence of columns in Excel sheet through Java
How to export data from database to excel sheet by using java swing in standalone project - Java Beginners
How to export data from database to excel sheet by using java swing... database to excel sheet by using java swing in standalone project.I get solution from... this api in order to create an excel sheet. We are providing you another code
Java swing: Export excel sheet data to JTable
Java swing: Export excel sheet data to JTable In this tutorial, you will learn.... Now to read these excel files, Java has provide two api's JExcel api and POI-HSSF api. Here we are using JExcel api to fetch the data from excel sheet

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.