Java Excel API: Difference between revisions
Appearance
Content deleted Content added
added external link to Selenium tutorial |
|||
Line 1: | Line 1: | ||
{{Use dmy dates|date=November 2023}} |
|||
{{Infobox software |
{{Infobox software |
||
| name = Java Excel API |
| name = Java Excel API |
||
Line 6: | Line 7: | ||
| developer = Andy Khan, Eric H. Jung |
| developer = Andy Khan, Eric H. Jung |
||
| latest release version = 2.6.12 |
| latest release version = 2.6.12 |
||
| latest release date = |
| latest release date = {{date|2012-10-08}} |
||
| latest preview version = |
| latest preview version = |
||
| operating system = [[Cross-platform]] |
| operating system = [[Cross-platform]] |
||
| programming language = [[Java (programming language)|Java]] |
| programming language = [[Java (programming language)|Java]] |
||
| genre = [[API]] to access [[Microsoft Excel]] [[file format|format]] |
| genre = [[API]] to access [[Microsoft Excel]] [[file format|format]] |
||
| license = [[GNU Lesser General Public License|GNU LGPL v2.1+]]<ref name=":sf_j" |
| license = [[GNU Lesser General Public License|GNU LGPL v2.1+]]<ref name=":sf_j"/> |
||
| website = {{URL|jexcelapi.sourceforge.net}} |
| website = {{URL|jexcelapi.sourceforge.net}} |
||
}} |
}} |
||
'''Java Excel API (a.k.a. JXL API)''' allows users to read, write, create, and modify sheets in an [[Microsoft Excel|Excel]] (.xls) workbook at runtime. It doesn't support .xlsx format.<ref name=":se_jaddf" |
'''Java Excel API (a.k.a. JXL API)''' allows users to read, write, create, and modify sheets in an [[Microsoft Excel|Excel]] (.xls) workbook at runtime. It doesn't support .xlsx format.<ref name=":se_jaddf"/> |
||
==Microsoft Excel support== |
==Microsoft Excel support== |
||
Line 94: | Line 95: | ||
} |
} |
||
} |
} |
||
</syntaxhighlight><ref name=":se"/> |
|||
</syntaxhighlight><ref name=":se">{{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|access-date = 1 February 2016|website = Selenium Easy|publisher = Selenium Easy}}</ref> |
|||
==See also== |
==See also== |
||
Line 102: | Line 103: | ||
==References== |
==References== |
||
{{Reflist |
{{Reflist|refs= |
||
<ref name=":sf_j">{{Cite web |
|||
| url = http://sourceforge.net/projects/jexcelapi/ |
|||
| title = jxlapi |
|||
| access-date = 2023-08-16 |
|||
| website = Sourceforge |
|||
| publisher = Sourceforge}}</ref> |
|||
<ref name=":se_jaddf">{{Cite book|title = Selenium Essentials |
|||
| last = Sams |
|||
| first = P. |
|||
| publisher = Packt publishing Ltd |
|||
| year = 2015 |
|||
| location = Birmingham |
|||
| pages = 133}}</ref> |
|||
<ref name=":se">{{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 |
|||
| access-date = 2016-02-01 |
|||
| website = Selenium Easy |
|||
| publisher = Selenium Easy}}</ref> |
|||
}} |
|||
==External links== |
==External links== |
||
* |
* [http://jexcelapi.sourceforge.net/ Java Excel API] |
||
* |
* [http://mvnrepository.com/artifact/net.sourceforge.jexcelapi/jxl MAVEN repository] |
||
* [https://www.seleniumeasy.com/jxl-tutorials Selenium tutorial] |
|||
[[Category:Microsoft Office-related software]] |
[[Category:Microsoft Office-related software]] |
Revision as of 18:25, 27 November 2023
![]() | |
Developer(s) | Andy Khan, Eric H. Jung |
---|---|
Stable release | 2.6.12
/ 8 October 2012 |
Written in | Java |
Operating system | Cross-platform |
Type | API to access Microsoft Excel format |
License | GNU LGPL v2.1+[1] |
Website | jexcelapi |
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();
}
}