JExcel API

Write Data with formatting information

We can pass the formatting information to Excel by overloading the constructor which takes an additional object containing the cell format information.

Formatting is required when ever you want to distinguish cell content with other cell contents. Generally, when we update the test cases in excel sheet, we keep all "PASS" in green color and Failed in Red color just to highlight the content.

The below syntax and example program helps to write data into excel sheet using formatting styles

How to Set Data into Excel sheet using jxl

The below example program explains how to write / set data in spreadsheet without any formatting such as fonts etc.

In order to write anything we need to first create a writable workbook as below which creates the workbook object.

WritableWorkbook workbook = Workbook.createWorkbook(new File("sampletestfile.xls"));

We can also use the existing excel sheet and write the data into excel sheet. But before doing write operations we need to make sure to take the copy of the original file

How to Read Excel file using Java

Normally, to read a data in excel, first we should have access to workbook, sheet which we want to read as workbook contains multiple sheets and if you want to read a particular cell we need location of a Cell.

In this article, we will discuss how to access workbook, sheet and a Cell using Jxl library Download jxl jar and add it to build path.