HOME FORUM BLOGS CONTACT LINKS FEEDBACK LOGIN REGISTER
 

JAVA DEVELOPER SITE - COMPLETE JAVA TUTORIALS

Read/Write Excel Sheet using Java



Newly Added TutorialNewly Added Tutorial


Java Exception Handling
Factory Design Pattern
Thread Creation in Java
Read a File in Java
Convert List to Array
Read Excel in Java
Setting thread priorities
Method Invocation Using Reflection
Ajax Basics
Stateless Session Beans Callback
Ajax Autocomplete in Java
Hello World Java
Hello World Java
Decision Table
Object Serialization
Singleton Pattern
Java Heap Size
Set Heap Size Eclipse
OutofMemory Exception in Java
Axis Web Services
Java C++ Difference
SOA Tutorials
Filenet Platform BPM
Eclipse Tips & Tricks
enterprise service bus (ESB)
Enterprise Application Integration (EAI)
JPA Basics
ORM
Marshalling & Unmarshalling XML
Marshalling & Unmarshalling XML
JAXP- Read Write XML

JAVA Tutorials

Collection Framework
Operators in Java
If-else Statement

Thread
File
Generics
Input-Output in java
File Stream
Java Methods
Java Arrays
Java Objects
Java Exception Handling
Java Inheritance Tutorial
Java Threads
Garbage collection

J2EE Tutorials

Servlets Tutorials
Introduction to Struts Framework
JSP Tutorials
SPRING Framework Tutorials
STRUTS Tutorials
HIBERNATE Tutorials
WEB-SERVICES Tutorials

Java Collections

MAP
SET
LIST
VECTOR

Advanced Java

Stateless Session Bean
Introduction to EJB
Stateful Session Bean
Java Design Patterns

BRMS Tutorial

ILOG
BLAZE ADVISOR
PEGA
Drools
BRMS
BPM
JRules for .NET
ilog jrules interview questions
ilog jrules certification dumps
Java Certification Study Guide
hibernate tutorial
hello world struts example

All Tutorial

php mysql tutorial
SCJP 1.5/1.6
SCWCD 1.5/1.6
Polymorphism
Thread Tutorial
Generics & Exceptions
Spring Struts Hibernate

 
 
 

Useful Java Links




Reading/Writing a Excel Sheet in Java
There are two good choices for reading & writing Microsoft Excel Spreadsheet files from Java, in a platform independent way, - jexcelapi and Jakarta POI (HSSF). Both of them provide nice interface to access Excel data structure and even generate new spreadsheet. I have done extensive tests with both of them for a high-profile project for a Fortune 500 company. Previously also I had successfully used HSSF for another high profile client. In the paragraphs below I present my conclusions and sample code for reading Excel spreadsheet from Java using both the libraries. Comparison of JExcelAPI with Jakarta-POI (HSSF)
1. JExcelAPI is clearly not suitable for important data. It fails to read several files. Even when it reads it fails on cells for unknown reasons. In short JExcelAPI isnt suitable for enterprise use.
2. HSSF is the POI Projects pure Java implementation of the Excel  97(-2002) file format. It is a mature product and was able to correctly and effortlessly read excel data generated from various sources, including non-MS Excel products like Open Office, and for various versions of Excel. It is very robust and well featured. Highly recommended.
3. Performance was never a consideration in our tests because a) data integrity is the single most important factor and b) there didnt appear to be any significant performance difference while running thetests; both of them were very fast. We didnt bother to time it for the above reasons.
How to read Excel Excel Spreadsheet from Java using Jakarta POI (HSSF)
try {

POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(file)); HSSFWorkbook wb = new HSSFWorkbook(fs);

HSSFSheet sheet = wb.getSheetAt(0);

 HSSFRow row; HSSFCell cell;

int rows; // No of rows

rows = sheet.getPhysicalNumberOfRows();

int cols = 0; // No of columns

int tmp = 0;

 // This trick ensures that we get the data properly even if it doesnt start from first few rows

for(int i = 0; i < 10 || i < rows; i++)

{

row = sheet.getRow(i);

if(row != null)

 { tmp = sheet.getRow(i).getPhysicalNumberOfCells();

if(tmp > cols) cols = tmp;

} }

for(int r = 0; r < rows; r++) {

row = sheet.getRow(r);

 if(row != null) { for(int c = 0; c < cols; c++) {

cell = row.getCell((short)c);

 if(cell != null)

{ // Your code here }

} } }

 } catch(Exception ioe) { ioe.printStackTrace(); }



If you need any urgent assistance on Read_Write_Excel_Sheet_Using_Java_POI_HSSF_API, kindly email your requirement to us at : info@javagenious.com or Contact-an-Expert. Our experts will try their best to solve your problem.

Keyword Tags: Read_Write_Excel_Sheet_Using_Java_POI_HSSF_API tutorial,Read_Write_Excel_Sheet_Using_Java_POI_HSSF_API in java,Concepts of Read_Write_Excel_Sheet_Using_Java_POI_HSSF_API,Java,J2EE,Interview Questions,Read_Write_Excel_Sheet_Using_Java_POI_HSSF_API Examples


Java Virtual Machine (JVM)

Most programming languages compile source code directly into machine code, suitable for execution on a particular microprocessor architecture. read more


Java Related Discussions

 
Javagenious.com

Interview Questions
Placement Papers
FAQs on J2EE
FAQs on JNDI
XML-Tutorials
Remote Web Services
Exception-Handling
JMS Tutorials
seam richfaces tutorial
richfaces live demo
jquery example demo
JQuery Tutorial and Source Code
JSF Tutorial
XSL Tutorial
J2EE JMS
CORBA Applications
Java CERTIFICATION
SCJP 1.5
SCJP 1.6
SCWCD 1.5
SCBCD
Mis
Ajax autosuggest autocomplete from database
Struts forms and validation with webflow
Java Apache POI Examples
JDBC Tutorial

Oracle
MYSQL Tutorial
php Tutorial
JQuery Examples
JQuery Tuorial
Upload Java File
JAXB Examples
PL-SQL Tutorial
Dojo AJAX
EJB Examples
Java IDE
Eclipse
NetBeans
IBM Rational Weblogic Workshop
Downloads
SCJP 1.6 Dumps
SCJP 1.5 DUMP
SCJP Material
SCWCD
Java Security
SCBCD Dumps
External Links
SUN Java
JOracle
Bea Weblogic
IBM
PHP Certification
Technical Interview Questions
Amazon Interview Questions
Google Interview Questions
Microsoft Interview Questions
IBM Interview Questions
Yahoo Interview Questions
HOME | FORUM | ABOUT | BLOGS | CONTACT-US