0

I am using JExcel API, to read the contents of a existing excel file.

I am trying to read a cell that contains a formula, and displays the calculated value in that cell. For example : 25 = (a1 * b1), where 456 is displayed in the cell. Using JExcel API, i can read the formula in the cell.But how do i read the calculated value of the formula like 456 (Number).

My Code

for(int i = 1; i < CS_BBH.getRows(); i++)
    {
         System.out.println(CS_BBH.getCell(13, i).getContents());
     if(ExcelWriteHelper.isNumeric(CS_BBH.getCell(13, i).getContents()))
            {
                val = Double.parseDouble(CS_BBH.getCell(13, i).getContents());
                if(val > 98)
                {
                    ExcelWriteHelper.addCells(CS_BBH, 13, i, CS_BBH.getCell(13, i).getContents(), cellGreenFormat);
                }
                else
                {
                    ExcelWriteHelper.addCells(CS_BBH, 13, i, CS_BBH.getCell(13, i).getContents(), cellYLFormat);
                }
            }
             }

Can i use any another why in jxl library to implementing formula and after then get real displaying calculated value.

because i can't use poi library for this application.

Please give me any suggestion.

  • 1
    Welcome to Stack Overflow! You need to give a bit more detail - show the code you're using to read the Excel file and the code you use to look at the cell contents. I assume you've tried `Cell.getContents()` - you might need to check `Cell.getCellFormat()` and if appropriate cast to a `NumberFormulaCell` where you can use `myCell.getValue()` and `myCell.getFormula()`. Please add info (code) to the question about what you've done already and we should be able to help. – J Richard Snape Jan 15 '15 at 09:58

1 Answers1

0

I guess JExcel it allows you to read or write Excel files. It gives only a representation of the content of that Excel file and is not a substitution for Excel. The formula would be computed in Excel only, not by JExcel.

user2963757
  • 107
  • 1
  • 1
  • 12