How to Read Excel File Java

preview_player
Показать описание
In this video tutorial we will learn how to integrate Java with excel to read excel file in java.

Microsoft Excel can be integrated with other programming languages to build powerful software applications.

Follow this easy step by step tutorial to learn how to read Excel file in Java by using a Java-Excel API

Step 1 - Creating a new Java Project

For that we have created a new java project in eclipse named "Open Excel File" and a class "ReadExcel" in the package reader.

Step 2 - Downloading API

To read excel file in java we need the Jxl library which does the I/O operation of the excel files.

On that page, click on jexcelapi and download it.

Step 3 - Importing the Library

Now the next step is to import the library to our project. For that, go to eclipse, move over file and click on Import.

Step 4 - Giving Import Source

Select the File System directory here and click on next.

Step 5 - Giving the Library Path

Now let us locate the JXL library which we have just downloaded

Step 6 - Inserting Library into the project

After that done, we have to browse and select our project where we want to import the library.

Step 7 - Finalizing the import

With all that taken care of, we just have to click on Finish.

After that we can see the JXL.jar in our project explorer.

Step 8 - Adding in build Path

After that we have to Right click on the library icon, hover over to build path and Click on the Add to build Path option.

Step 9 - Code

Now let's go through the code.

First we open the file using file descriptor FILE. Then we create a workbook object to access the excel file.

The getSheet method allows us to access the sheet of the workbook. The getColumn and getRows method returns the column and rows of the file and the getContent method returns the content of the file.

Step 10 - Inside Main

Let us move on to Main.

We are creating an object test of our class. In the setInputFile method, we have to give the path of the excel file we want to read.

Step 11 - Debug

So now, let's run the program.

After running the code, we will get the contents of the file in console.

And this is how we can read excel file in java.
Рекомендации по теме
Комментарии
Автор

❗ Subscribe To Our Main YouTube Channel

howtechoffice
Автор

It worked for me perfectly, thanks for the video. I especially liked how you not talk about unnecessary things for minutes!

peebleish
Автор

@1:32 maybe in a tutorial for writing code, you should write code.

sawyerwest
Автор

Thank you so much!!! I have struggled for a while to get this

STIKO
Автор

Very helpful. Thanks a lot. Can you please provide with the code for reading and writing with excel.

AshishLohia
Автор

Its an amazing tutorial. Please save your files in Execel 97-2003 format(.xls) else it will give exceptions.

__azt
Автор

Is there another import that will allow this to work with the .xlsx extension?

easiedlecki
Автор

now lets paste the code we haven't written...

roddz
Автор

Would be helpful if I got to see which classes were being imported

skalps
Автор

Thanks, but what about the .xlsx extension? Is there another import?

bill
Автор

Thanks a lot. I have been trying to import excel sheets, but there is no API from Oracle

mike-zxhf
Автор

Hello! At 1:31 Where do I find the code

matsnystrom
Автор

does it also work with online excel spreadsheets?

made
Автор

says on the website that only workbooks 2003 or earlier can be used with it...

leavenless
Автор

Is it possible with some changes, to read file of .xlsx format? If yes how?

NavdeepKaur-whpl
Автор

jxl.read.biff.BiffException: Unable to recognize OLE stream its showing this error

projavadevelopers
Автор

where is the code ? I could not find :(

emretamer
Автор

it says inputFile cant be resolved to a variable help please

cemkocak
Автор

Can I get a code of a project, please

sergeya
Автор

Didn't u miss something ? maybe the name of the code u inserted??? This is useless so far for beginners

krajcsovicsnorbert