Solved

How to read xls or cvs file in java

Posted on 2010-11-26
9
905 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
starter POM and spring-boot-starter,  spring-boot-web 2 54
Java Loop 6 61
servlet example 17 32
mysql jsp example issue 32 35
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…
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…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

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