How to read xls or cvs file in java

Posted on 2010-11-26
Last Modified: 2012-05-10

How to read xls or cvs file in java ?
LVL 86

Accepted Solution

CEHJ earned 100 total points
ID: 34218653
Two different things: xls is a binary format:

A csv file is a text file and can be read using standard Java or a  csv reader, such as Ostermiller CSVReader or OpenCSV
LVL 10

Assisted Solution

Hegemon earned 100 total points
ID: 34218732
Excel (xls) files can be dealt with like database tables using a JDBC driver, for example, this one:

Assisted Solution

robthewolf earned 100 total points
ID: 34219006
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

LVL 92

Expert Comment

ID: 34219937

Assisted Solution

subratabiswas earned 100 total points
ID: 34220390
1) CSV files can be processed using standard java string processing. You will have to consider field delimeter, date format etc., but they are forms of text processing only.

2) Binary XLS files can be processed using the very useful Java APIs provided by Apache POI project. POI is very comprehensive and covers different types of Microsoft documents. For processing XLS, you will only need a small area in POI, called HSSF.


There is standard javadoc available on whole POI at . You will on ly need to focus on those prefixed by HSSF, starting with HSSFWorkbook.
LVL 11

Assisted Solution

by:Bruce Smith
Bruce Smith earned 100 total points
ID: 34220986
@subratabiswas is correct. Probably the most versatile tool that I've used to read/write .xls files via Java. The site there at offers many examples and is fairly easy to implement.

There is a decent tutorial here ( of how to read an Excel spreadsheet so that you can see if this might work for you before you actually download the POI api and 'get your hands dirty'.

Also, be sure to read the limitations before you begin:

PS: Don't let the acronyms scare you though:
POI = "Poorly Obfuscated Implementation"
HSSF = "Horrible SpreadSheet Format"
LVL 92

Expert Comment

ID: 34244572
you should be able to find what you need to use POI here
LVL 20

Author Closing Comment

by:Sathish David Kumar N
ID: 34245771
LVL 86

Expert Comment

ID: 34247276

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
print map entry 34 72
jdbc error in jsp application 20 63
going to wrong jsp page 2 33
swing controls 2 16
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This video teaches viewers about errors in exception handling.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question