Solved

How to read xls or cvs file in java

Posted on 2010-11-26
9
898 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 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
 
LVL 92

Expert Comment

by:objects
ID: 34219937
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

930 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now