Pages Navigation Menu

Coding is much easier than you think

Read Excel with Java (Jexcel-api)

Read Excel with Java  (Jexcel-api)

In our previous article we have In our next article I have implemented Write Excel in Java using Jexcel-api in this article demonstrate how to read Excel files with the Java Excel API.
Since I have explained about Jexcel api in my previous article, so I’m not going to explain here again.

Download – Java Excel library


package com.simplecode.reader;


import jxl.Cell;
import jxl.CellType;
import jxl.Sheet;
import jxl.Workbook;

public class ReadExcel {

  public static void main(String[] args) throws IOException {
    ReadExcel test = new ReadExcel();

  private String inputFile;

  public void setInputFile(String inputFile) {
    this.inputFile = inputFile;

  public void read() throws IOException  {
    File inputWorkbook = new File(inputFile);
    Workbook w;
    try {
      w = Workbook.getWorkbook(inputWorkbook);
      // Get the first sheet
      Sheet sheet = w.getSheet(0);
      // Loop over first 10 column and lines

      for (int j = 0; j < sheet.getColumns(); j++) {
        for (int i = 0; i < sheet.getRows(); i++) {
          Cell cell = sheet.getCell(j, i);
          CellType type = cell.getType();
          if (type == CellType.LABEL) {
            System.out.println("I got a label "
                + cell.getContents());

          if (type == CellType.NUMBER) {
            System.out.println("I got a number "
                + cell.getContents());

    } catch (BiffException e) {

About Mohaideen Jamil

I'm a Full stack developer of IT exp in J2EE, AngularJs, MicroServices, Docker, Spring (Boot, MVC, Cloud), Bluemix, DevOps. Follow me on Facebook or Google Plus. If you like my tutorials, consider making a donation to this charity, thanks.

%d bloggers like this: