请输入您要查询的百科知识:

 

词条 JXL (API)
释义

  1. Microsoft Excel support

  2. Usage

     Example 

  3. See also

  4. References

  5. External links

{{Infobox software
| name = JXL
| screenshot =
| caption =
| developer = Alex Lynch
| latest release version = 2.6.12
| latest release date =
| latest preview version =
| operating system = Cross-platform
| programming language = Java
| genre = API to access Microsoft Excel format
| license = GNU GPL v2[1]
| website = {{URL|jexcelapi.sourceforge.net}}
}}JXL API (a.k.a. Java Excel API) is the most widely used API for executing Selenium data-driven tests{{Citation needed|reason=Reliable source needed|date=December 2018}}, which 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

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

Usage

JXL 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

  • Apache POI
  • Aspose API
  • Open Packaging Conventions
  • Office Open XML software

References

1. ^{{Cite web|url = http://sourceforge.net/projects/jxl/|title = jxl|date = |accessdate = 1 February 2016|website = Sourceforge|publisher = Sourceforge|last = |first = }}
2. ^{{Cite book|title = Selenium Essentials|last = Sams|first = P.|publisher = Packt publishing Ltd|year = 2015|location = Birmingham|volume = |pages = 133}}
3. ^{{Cite web|url =http://www.seleniumeasy.com/jxl-tutorials/set-data-into-excelsheet-with-jxl|title = How to Set Data into Excel sheet using jxl|date = |accessdate = 1 February 2016|website = Selenium Easy|publisher = Selenium Easy|last = |first = }}

External links

  • {{citation | url = http://sourceforge.net/projects/jxl/| title = jxl}}
  • {{citation | url = http://jexcelapi.sourceforge.net/| title = Java Excel API}}
  • {{Citation | url = http://mvnrepository.com/artifact/net.sourceforge.jexcelapi/jxl| title = Jxl}} - MAVEN repository

4 : Microsoft Office-related software|Java platform|Java (programming language) libraries|Cross-platform free software

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/14 4:08:25