Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to read xls or cvs file in java

Posted on 2010-11-26
9
Medium Priority
?
948 Views
Last Modified: 2012-05-10
Hi,

How to read xls or cvs file in java ?
0
Comment
9 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 400 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 400 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 400 total points
ID: 34219006
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 92

Expert Comment

by:objects
ID: 34219937
0
 
LVL 4

Assisted Solution

by:subratabiswas
subratabiswas earned 400 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 400 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

Technology Partners: 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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn different types of Android Layout and some basics of an Android App.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

824 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