Solved

How to read xls or cvs file in java

Posted on 2010-11-26
9
923 Views
Last Modified: 2012-05-10
Hi,

How to read xls or cvs file in java ?
0
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 86

Accepted Solution

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

http://technojeeves.com/joomla/index.php/free/113-read-excel-spreadsheet-with-java

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

Assisted Solution

by:Hegemon
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: http://xlsjdbc.sourceforge.net/
0
 
LVL 8

Assisted Solution

by:robthewolf
robthewolf earned 100 total points
ID: 34219006
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 92

Expert Comment

by:objects
ID: 34219937
0
 
LVL 4

Assisted Solution

by:subratabiswas
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.

a) http://poi.apache.org/
b) http://poi.apache.org/spreadsheet/index.html

There is standard javadoc available on whole POI at http://poi.apache.org/apidocs/index.html . You will on ly need to focus on those prefixed by HSSF, starting with HSSFWorkbook.
0
 
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 poi.apache.org offers many examples and is fairly easy to implement.

There is a decent tutorial here (http://www.javabeat.net/articles/41-apache-poi-reading-excel-sheet-using-java-1.html) 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: http://poi.apache.org/spreadsheet/limitations.html

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

Expert Comment

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

Author Closing Comment

by:Sathish David Kumar N
ID: 34245771
Thanks
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 34247276
:)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

739 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