JExcel API provides various classes to create, read, write data to Excel documents at runtime. The required platform is JVM which means the code developed with JExcel can be run on Windows and Linux without any modification.

The example below shows how to read data from an Excel document using JExcel API.

 import java.io.File;
import java.io.*;
import jxl.*;
import java.util.*;
import jxl.Workbook;
import jxl.read.biff.*;

class readXls 
{
  public static void main(String[] args) 
  {
    try
    {
      String filename = "input.xls";
      WorkbookSettings ws = new WorkbookSettings();
      ws.setLocale(new Locale("en", "EN"));

      Workbook workbook = Workbook.getWorkbook(
        new File(filename),ws);

      Sheet s  = workbook.getSheet(0);
      Sheet s1  = workbook.getSheet(1);
      readDataSheet(s1);
      readImageSheet(s);
      workbook.close();      
    }
    catch (IOException e)
    {
      e.printStackTrace();
    }
    catch (BiffException e)
    {
      e.printStackTrace();
    }
    
  }

  private static void readDataSheet(Sheet s)
  {
    // Find the labeled cell from sheet
    LabelCell lc = s.findLabelCell("Date");
    System.out.println(lc.getString());

    //gets the value of cell at specified column and row
    DateCell dc =(DateCell) s.getCell(0,1);
    System.out.println(dc.getDate());

    lc = s.findLabelCell("Add 2 cells");
    System.out.println(lc.getString());

    NumberCell c =(NumberCell) s.getCell(4,1);
    System.out.println(c.getValue());

    c =(NumberCell) s.getCell(4,2);
    System.out.println(c.getValue());

    NumberFormulaCell nc =(NumberFormulaCell) s.getCell(4,3);
    System.out.println(nc.getValue());

  }

  private static void readImageSheet(Sheet s)
  {
    LabelCell lc = s.findLabelCell("Image");
    System.out.println(lc.getString());

    // Gets the image stored in excel document
    Image c = s.getDrawing(0);
    System.out.println(c.getImageFile());

  }
}