2008-10-09 02:07:36 -04:00
|
|
|
/* ====================================================================
|
|
|
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
contributor license agreements. See the NOTICE file distributed with
|
|
|
|
this work for additional information regarding copyright ownership.
|
|
|
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
(the "License"); you may not use this file except in compliance with
|
|
|
|
the License. You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
==================================================================== */
|
|
|
|
|
|
|
|
package org.apache.poi.hssf.usermodel;
|
|
|
|
|
|
|
|
import org.apache.poi.ss.formula.EvaluationCell;
|
|
|
|
import org.apache.poi.ss.formula.EvaluationSheet;
|
2016-07-04 05:45:46 -04:00
|
|
|
import org.apache.poi.ss.usermodel.CellType;
|
2016-07-04 07:54:20 -04:00
|
|
|
import org.apache.poi.util.Internal;
|
2008-10-09 02:07:36 -04:00
|
|
|
/**
|
|
|
|
* HSSF wrapper for a cell under evaluation
|
|
|
|
*/
|
|
|
|
final class HSSFEvaluationCell implements EvaluationCell {
|
|
|
|
|
|
|
|
private final EvaluationSheet _evalSheet;
|
|
|
|
private final HSSFCell _cell;
|
|
|
|
|
|
|
|
public HSSFEvaluationCell(HSSFCell cell, EvaluationSheet evalSheet) {
|
|
|
|
_cell = cell;
|
|
|
|
_evalSheet = evalSheet;
|
|
|
|
}
|
|
|
|
public HSSFEvaluationCell(HSSFCell cell) {
|
2008-12-03 00:07:31 -05:00
|
|
|
this(cell, new HSSFEvaluationSheet(cell.getSheet()));
|
2008-10-09 02:07:36 -04:00
|
|
|
}
|
2016-07-04 05:45:46 -04:00
|
|
|
@Override
|
2008-12-03 00:07:31 -05:00
|
|
|
public Object getIdentityKey() {
|
|
|
|
// save memory by just using the cell itself as the identity key
|
|
|
|
// Note - this assumes HSSFCell has not overridden hashCode and equals
|
|
|
|
return _cell;
|
2008-10-09 02:07:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public HSSFCell getHSSFCell() {
|
|
|
|
return _cell;
|
|
|
|
}
|
2016-07-04 05:45:46 -04:00
|
|
|
@Override
|
2008-10-09 02:07:36 -04:00
|
|
|
public boolean getBooleanCellValue() {
|
|
|
|
return _cell.getBooleanCellValue();
|
|
|
|
}
|
2016-07-04 07:54:20 -04:00
|
|
|
/**
|
|
|
|
* Will return {@link CellType} in a future version of POI.
|
|
|
|
* For forwards compatibility, do not hard-code cell type literals in your code.
|
|
|
|
*
|
|
|
|
* @return cell type
|
|
|
|
*/
|
2016-07-04 05:45:46 -04:00
|
|
|
@Override
|
2016-07-04 07:54:20 -04:00
|
|
|
public int getCellType() {
|
2008-10-09 02:07:36 -04:00
|
|
|
return _cell.getCellType();
|
|
|
|
}
|
2016-07-04 08:35:49 -04:00
|
|
|
/**
|
|
|
|
* @since POI 3.15 beta 3
|
|
|
|
* @deprecated POI 3.15 beta 3.
|
|
|
|
* Will be deleted when we make the CellType enum transition. See bug 59791.
|
|
|
|
*/
|
2016-07-05 19:22:49 -04:00
|
|
|
@Internal(since="POI 3.15 beta 3")
|
2016-07-04 07:54:20 -04:00
|
|
|
@Override
|
|
|
|
public CellType getCellTypeEnum() {
|
|
|
|
return _cell.getCellTypeEnum();
|
|
|
|
}
|
2016-07-04 05:45:46 -04:00
|
|
|
@Override
|
2008-10-09 02:07:36 -04:00
|
|
|
public int getColumnIndex() {
|
2008-10-09 03:44:37 -04:00
|
|
|
return _cell.getColumnIndex();
|
2008-10-09 02:07:36 -04:00
|
|
|
}
|
2016-07-04 05:45:46 -04:00
|
|
|
@Override
|
2008-10-09 02:07:36 -04:00
|
|
|
public int getErrorCellValue() {
|
|
|
|
return _cell.getErrorCellValue();
|
|
|
|
}
|
2016-07-04 05:45:46 -04:00
|
|
|
@Override
|
2008-10-09 02:07:36 -04:00
|
|
|
public double getNumericCellValue() {
|
|
|
|
return _cell.getNumericCellValue();
|
|
|
|
}
|
2016-07-04 05:45:46 -04:00
|
|
|
@Override
|
2008-10-09 02:07:36 -04:00
|
|
|
public int getRowIndex() {
|
|
|
|
return _cell.getRowIndex();
|
|
|
|
}
|
2016-07-04 05:45:46 -04:00
|
|
|
@Override
|
2008-10-09 02:07:36 -04:00
|
|
|
public EvaluationSheet getSheet() {
|
|
|
|
return _evalSheet;
|
|
|
|
}
|
2016-07-04 05:45:46 -04:00
|
|
|
@Override
|
2016-07-05 19:26:32 -04:00
|
|
|
public String getStringCellValue() {
|
|
|
|
return _cell.getRichStringCellValue().getString();
|
2016-07-04 07:54:20 -04:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Will return {@link CellType} in a future version of POI.
|
|
|
|
* For forwards compatibility, do not hard-code cell type literals in your code.
|
|
|
|
*
|
|
|
|
* @return cell type of cached formula result
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public int getCachedFormulaResultType() {
|
|
|
|
return _cell.getCachedFormulaResultType();
|
|
|
|
}
|
2016-07-04 08:35:49 -04:00
|
|
|
/**
|
|
|
|
* @since POI 3.15 beta 3
|
|
|
|
* @deprecated POI 3.15 beta 3.
|
|
|
|
* Will be deleted when we make the CellType enum transition. See bug 59791.
|
|
|
|
*/
|
2016-07-05 19:22:49 -04:00
|
|
|
@Internal(since="POI 3.15 beta 3")
|
2016-07-04 05:45:46 -04:00
|
|
|
@Override
|
2016-07-05 19:26:32 -04:00
|
|
|
public CellType getCachedFormulaResultTypeEnum() {
|
|
|
|
return _cell.getCachedFormulaResultTypeEnum();
|
|
|
|
}
|
|
|
|
}
|