Java Excel API Projects

Java Excel API Project 1

how to read values of FormulaNumberCell of an excel file via jexcel
Previous Home Next


This example demonstrates how to read the values from a FormulaNumberCell of an excel worksheet using the JExcel API. 

To read a workbook you have to import the package.
 To display the value contained in the Formula Number Cell we have used the getValue() method on the cell.

In this program we have created a class named ReadNumberFormulaCellSheetXL class, whose main method contains the code for reading the Number Cells and FormulaNumberCells of an excel worksheet.


import jxl.*;
import jxl.Workbook;
import jxl.write.WriteException;
import java.util.Locale;
public class ReadNumberFormulaCellSheetXL {

	 * @param args
	public static void main(String[] args) throws IOException, WriteException, BiffException{
		// TODO Auto-generated method stub
        	File f1=new File("F:/JAVA PROJECTS/Jexcel/src/r4r/co/in/firstsheet.xls");
        	WorkbookSettings ws=new WorkbookSettings();
        	ws.setLocale(new Locale("er","ER"));
        	Workbook workbook=Workbook.getWorkbook(f1,ws); //opening an existing workbook 
        	Sheet readsheet=workbook.getSheet(0);
        	System.out.println(readsheet.getName());    // getting the name of sheet contained in the workbook
        	LabelCell lcobj=readsheet.findLabelCell("Sum");    // finding the label name Sum in the sheet
        	System.out.println(lcobj.getString());             // if exists displaying the name of label
        	NumberCell nc=(NumberCell)readsheet.getCell(0,1);   // getting the NumberCell of sheet via getCell() method by doing proper casting
        	System.out.println(nc.getValue());                   // printing the value contained int the cell
        	NumberFormulaCell nfc=(NumberFormulaCell)readsheet.getCell(0, 3); // getting the FormulaNumberCell of sheet via getCell()method
        	System.out.println(nfc.getValue());                            //printing the value
        catch(IOException e)
        catch(BiffException e)


Previous Home Next