예제 #1
0
 protected CellValue getCellValueAt(int index) {
   if (index < 0 || index >= numOfCells) {
     throw new IndexOutOfBoundsException(
         "Index must be between 0 and " + (numOfCells - 1) + " (inclusive), given: " + index);
   }
   int firstRow = cellRangeAddress.getFirstRow();
   int firstCol = cellRangeAddress.getFirstColumn();
   int lastCol = cellRangeAddress.getLastColumn();
   int width = lastCol - firstCol + 1;
   int rowIndex = firstRow + index / width;
   int cellIndex = firstCol + index % width;
   Row row = sheet.getRow(rowIndex);
   return (row == null) ? null : evaluator.evaluate(row.getCell(cellIndex));
 }
예제 #2
0
  public HSSFBookImpl(String bookname, InputStream is) throws IOException {
    super(is);
    _bookname = bookname;

    FunctionResolver resolver =
        (FunctionResolver) BookHelper.getLibraryInstance(FunctionResolver.CLASS);
    if (resolver == null) resolver = new DefaultFunctionResolver();

    // http://tracker.zkoss.org/browse/ZSS-218
    UDFFinder udff = resolver.getUDFFinder();
    if (udff != null) {
      insertToolPack(0, udff);
    }
    _evaluator =
        HSSFFormulaEvaluator.create(this, NoCacheClassifier.instance, TolerantUDFFinder.instance);
    _bookEvaluator = _evaluator.getWorkbookEvaluator();
    _bookEvaluator.setDependencyTracker(resolver.getDependencyTracker(this));
    _functionMapper = new JoinFunctionMapper(resolver.getFunctionMapper());
    _variableResolver = new JoinVariableResolver();
    _helper = new HSSFWorkbookHelper(this);
  }