Solved

How to read xls or cvs file in java

Posted on 2010-11-26
9
886 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
Comment Utility
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
Comment Utility
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
Comment Utility
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 4

Assisted Solution

by:subratabiswas
subratabiswas earned 100 total points
Comment Utility
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:patsmitty
patsmitty earned 100 total points
Comment Utility
@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
Comment Utility
you should be able to find what you need to use POI here
0
 
LVL 20

Author Closing Comment

by:Sathish David Kumar N
Comment Utility
Thanks
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
:)
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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 will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

772 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

14 Experts available now in Live!

Get 1:1 Help Now