Jexcel

Java Excel API Projects

Java Excel API Project 1

adplus-dvertising
Introduction of Jexcel

JExcel API refers as Java Excel API .JExcel is an open source java API by sourceforge. JExcel(Java Excel API) is used to read, write, and modify excel spreadsheets. Java developers can read data from database or xml or from any other resources through JExcel.

JExcel API Java developers can read, write and modify excel spreadsheets dynamically. We can make excel sheet in different format. We can set background colors ,foreground colors ,we can set boards of cells etc by using JExcel API.

JExcel API allow developers to read a excel spreadsheet and modify it as per as requirements .Jexcel can use Web based applications as well as any Desktop based applications. We can used Jexcel with JSP and Servlet .

To make a program ( or make a excel spreadsheet ) with JExcel API we need only JDK only. Here in this section we will covers JExcel tutorials and JExcel Examples. We will cover also how we can make excel sheet in different formats?

Jexcel Tutorials and Interview Question
Features of Jexcel

JExcel API have wonderful features like

  • It is used to create a workbook.
  • JExcel API helps to create a worksheet with given name.
  • This API formatted cell with bold, italic , border and borderline etc.
  • Add label to sheet with or without formatting.
  • Add Integer to sheet with or without formatting.6.Wrap text data in Cell.
Limitations of JExcel

JExcelApi does not generate or chart, graph or macro information. This information is however preserved when spreadsheets are copied. When adding images to a sheet, only PNG image formats are supported .

Example of Jexcel
First Excel Spreadsheets Using JExcel API

In this we are going to create first example of JExcel API.then we are going to create a work space and excel sheet. To create excel spread sheet we have to create an object of WritableWorkbook .To create it Jexcel API provides a static method createWorkbook() of WorkBook class .In this createWorkbook() method we have pass file name with .xls extension.

Then we have to create a sheet .For this WritableWorkbook class has a method createSheet(String sheetname,int sheetnumner) which return type is WritableSheet. After that store this object into a variable of WritableSheet To add some value in cell we can use addCell(Label label) method provided in WritableSheet class. The Label class is used to create label and add on cell. Finally write() method of WritableWorkbook class to write on workbook and at last close the workbook.

/*
 * Save as a FirstApplet.java
 * Program define complete Life cycle of applet.
 */
package r4r.co.in;
import java.awt.*;
public class FirstApplet extends java.applet.Applet {
    //define a private label
    private Label label;
    /*
     * Initialization method that will be called after the applet is loaded
     * into the browser.
     */
    public void init() {
        setBackground(Color.orange);
    }
    public void start() {
        /*
         * Start method is call after the applet is completely load
         * inside a AppletViewer/Browser
         */
        label = new Label("R4R Tech Soft! Welcome:");
        add(label);
    }
    public void stop() {
        //Stop method is call when close button is click
    }
    public void destroy() {
        //Method call After Stop method for Finally unload the applet
    }
    public void paint(Graphics g) {
        /*
         *Method used for providing Graphic in applet.
         * Call at the run time
         */
        label.update(g);
    }
}