To install click the Add extension button. That's it.

The source code for the WIKI 2 extension is being checked by specialists of the Mozilla Foundation, Google, and Apple. You could also do it yourself at any point in time.

4,5
Kelly Slayton
Congratulations on this excellent venture… what a great idea!
Alexander Grigorievskiy
I use WIKI 2 every day and almost forgot how the original Wikipedia looks like.
Live Statistics
English Articles
Improved in 24 Hours
Added in 24 Hours
What we do. Every page goes through several hundred of perfecting techniques; in live mode. Quite the same Wikipedia. Just better.
.
Leo
Newton
Brights
Milds

Java Excel API

From Wikipedia, the free encyclopedia

Java Excel API (a.k.a. JXL API) allows users to read, write, create, and modify sheets in an Excel (.xls) workbook at runtime. It doesn't support .xlsx format.[2]

Microsoft Excel support

Java Excel API supports Excel documents with versions Excel 95, 97, 2000, XP, and 2003. These documents hold the extension .xls.[2]

Usage

Java Excel API is widely used with Selenium.

Example

Sample code to write to an Excel file might look like as follows:

import java.io.File;
import jxl.Workbook;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.Label;
import jxl.write.WriteException;

public class DataSheet
{
    private Workbook wbook;
    private WritableWorkbook wwbCopy;
    private WritableSheet shSheet;

    public void readExcel()
    {
        try
        {
            wbook = Workbook.getWorkbook(new File("path/testSampleData.xls"));
            wwbCopy = Workbook.createWorkbook(new File("path/testSampleDataCopy.xls"), wbook);
            shSheet = wwbCopy.getSheet(0);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
   
    public void setValueIntoCell(String strSheetName, int iColumnNumber, int iRowNumber, String strData) throws WriteException
    {
        WritableSheet wshTemp = wwbCopy.getSheet(strSheetName);
        Label labTemp = new Label(iColumnNumber, iRowNumber, strData);
               
        try 
        {
            wshTemp.addCell(labTemp);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
   
    public void closeFile()
    {
        try 
        {
            // Closing the writable work book
            wwbCopy.write();
            wwbCopy.close();

            // Closing the original work book
            wbook.close();
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
   
    public static void main(String[] args) throws WriteException
    {
        DataSheet ds = new DataSheet();
        ds.readExcel();
        ds.setValueIntoCell("sheet1", 5, 1, "PASS");
        ds.setValueIntoCell("sheet1", 5, 2, "FAIL");
        ds.setValueIntoCell("sheet1", 5, 3, "PASS");
        ds.closeFile();
    }
}

[3]

See also

References

  1. ^ "jxlapi". Sourceforge. Retrieved 16 August 2023.
  2. ^ a b Sams, P. (2015). Selenium Essentials. Birmingham: Packt publishing Ltd. p. 133.
  3. ^ "How to Set Data into Excel sheet using jxl". Selenium Easy. Retrieved 1 February 2016.

External links

This page was last edited on 29 January 2024, at 04:20
Basis of this page is in Wikipedia. Text is available under the CC BY-SA 3.0 Unported License. Non-text media are available under their specified licenses. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc. WIKI 2 is an independent company and has no affiliation with Wikimedia Foundation.