import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.formula.ptg.ExpPtg;
import org.apache.poi.ss.formula.ptg.Ptg;
-import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellBase;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.CellValue;
import org.apache.poi.ss.usermodel.Comment;
import org.apache.poi.ss.usermodel.FormulaError;
-import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.ss.usermodel.Hyperlink;
import org.apache.poi.ss.usermodel.RichTextString;
import org.apache.poi.ss.util.CellAddress;
public void setCellValue(Date value)
{
if(value == null) {
- setCellType(CellType.BLANK);
+ setBlank();
return;
}
public void setCellValue(Calendar value)
{
if(value == null) {
- setCellType(CellType.BLANK);
+ setBlank();
return;
}
return styleIndex;
}
}
+
CellRange<HSSFCell> result = getCellRange(range);
// clear all cells in the range
for (Cell c : result) {
- c.setCellType(CellType.BLANK);
+ c.setBlank();
}
return result;
}
}
public void copyValue(Cell destCell) {
switch (_cellType) {
- case BLANK: destCell.setCellType(CellType.BLANK); return;
+ case BLANK: destCell.setBlank(); return;
case NUMERIC: destCell.setCellValue(_numberValue); return;
case BOOLEAN: destCell.setCellValue(_booleanValue); return;
case STRING: destCell.setCellValue(_stringValue); return;
destCell.setCellValue(srcCell.getNumericCellValue());
break;
case BLANK:
- destCell.setCellType(CellType.BLANK);
+ destCell.setBlank();
break;
case BOOLEAN:
destCell.setCellValue(srcCell.getBooleanCellValue());
@Override
public void setCellValue(Date value) {
if(value == null) {
- setCellType(CellType.BLANK);
+ setBlank();
return;
}
@Override
public void setCellValue(Calendar value) {
if(value == null) {
- setCellType(CellType.BLANK);
+ setBlank();
return;
}
((RichTextValue) _value).setValue(value);
}
} else {
- setCellType(CellType.BLANK);
+ setBlank();
}
}
((PlainStringValue) _value).setValue(value);
}
} else {
- setCellType(CellType.BLANK);
+ setBlank();
}
}
@Override
public void setCellValue(RichTextString str) {
if(str == null || str.getString() == null){
- setCellType(CellType.BLANK);
+ setBlank();
return;
}
@Override
public void setCellValue(Date value) {
if(value == null) {
- setCellType(CellType.BLANK);
+ setBlank();
return;
}
@Override
public void setCellValue(Calendar value) {
if(value == null) {
- setCellType(CellType.BLANK);
+ setBlank();
return;
}
arrayFormulas.remove(range);
CellRange<XSSFCell> cr = getCellRange(range);
for (XSSFCell c : cr) {
- c.setCellType(CellType.BLANK);
+ c.setBlank();
}
return cr;
}
if (row != null) {
XSSFCell cell = row.getCell(cellRef.getCol());
if (cell != null) {
- cell.setCellType(CellType.BLANK);
+ cell.setBlank();
cell.setCellStyle(null);
}
}
*/
@Override
@Ignore
- public void setCellType_BLANK_removesArrayFormula_ifCellIsPartOfAnArrayFormulaGroupContainingOnlyThisCell() {
+ public void setBlank_removesArrayFormula_ifCellIsPartOfAnArrayFormulaGroupContainingOnlyThisCell() {
}
/**
@Override
@Ignore
@Test // <- annotation is necessary to override expected exception
- public void setCellType_BLANK_throwsISE_ifCellIsPartOfAnArrayFormulaGroupContainingOtherCells() {
+ public void setBlank_throwsISE_ifCellIsPartOfAnArrayFormulaGroupContainingOtherCells() {
}
@Override
validateCells(sheet);
XSSFTestDataSamples.writeOutAndReadBack(wb1).close();
- sheet.getRow(6).getCell(0).setCellType(CellType.BLANK); // go
+ sheet.getRow(6).getCell(0).setBlank(); // go
XSSFTestDataSamples.writeOutAndReadBack(wb1).close();
sheet.getRow(7).getCell(0).setCellValue((String) null); // go
assertEquals("A$1*2", sheet.getRow(ROW_IX).getCell(1).getCellFormula());
cell = sheet.getRow(ROW_IX).getCell(1);
- cell.setCellType(CellType.BLANK);
+ cell.setBlank();
assertEquals(3, countSharedFormulas(sheet));
wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
Row row = sheet.createRow(0);
Cell cell = row.createCell(0);
- cell.setCellType(CellType.BLANK);
+ cell.setBlank();
assertNull(null, cell.getDateCellValue());
assertFalse(cell.getBooleanCellValue());
assertEquals("", cell.toString());
public void setCellValue(String cellRefText, double value) {
HSSFCell cell = getOrCreateCell(cellRefText);
// be sure to blank cell, in case it is currently a formula
- cell.setCellType(CellType.BLANK);
+ cell.setBlank();
// otherwise this line will only set the formula cached result;
cell.setCellValue(value);
_evaluator.notifyUpdateCell(wrapCell(cell));
}
public void clearCell(String cellRefText) {
HSSFCell cell = getOrCreateCell(cellRefText);
- cell.setCellType(CellType.BLANK);
+ cell.setBlank();
_evaluator.notifyUpdateCell(wrapCell(cell));
}
cv = fe.evaluate(cellA1);
assertEquals(3.7, cv.getNumberValue(), 0.0);
- cellB1.setCellType(CellType.BLANK);
+ cellB1.setBlank();
fe.notifyUpdateCell(cellB1);
cv = fe.evaluate(cellA1); // B1 was used to evaluate A1
assertEquals(2.2, cv.getNumberValue(), 0.0);
public void testRandBetweenTopBlank() {
bottomValueCell.setCellValue(-1);
- topValueCell.setCellType(CellType.BLANK);
+ topValueCell.setBlank();
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
evaluator.clearAllCachedResultValues();
evaluator.evaluateFormulaCell(formulaCell);
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
assertEquals(ErrorEval.NUM_ERROR.getErrorCode(), formulaCell.getErrorCellValue());
bottomValueCell.setCellValue(1);
- topValueCell.setCellType(CellType.BLANK);
+ topValueCell.setBlank();
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
evaluator.clearAllCachedResultValues();
evaluator.evaluateFormulaCell(formulaCell);
}
/**
- * Make sure that cell.setCellType(CellType.BLANK) preserves the cell style
+ * Make sure that cell.setBlank() preserves the cell style
*/
@Test
public void testSetBlank_bug47028() throws Exception {
Cell cell = wb.createSheet("Sheet1").createRow(0).createCell(0);
cell.setCellStyle(style);
int i1 = cell.getCellStyle().getIndex();
- cell.setCellType(CellType.BLANK);
+ cell.setBlank();
int i2 = cell.getCellStyle().getIndex();
assertEquals(i1, i2);
wb.close();
@Test
- public void setCellType_BLANK_removesArrayFormula_ifCellIsPartOfAnArrayFormulaGroupContainingOnlyThisCell() {
+ public void setBlank_removesArrayFormula_ifCellIsPartOfAnArrayFormulaGroupContainingOnlyThisCell() {
Cell cell = getInstance();
cell.getSheet().setArrayFormula("1", CellRangeAddress.valueOf("A1"));
assertTrue(cell.isPartOfArrayFormulaGroup());
assertEquals("1", cell.getCellFormula());
- cell.setCellType(CellType.BLANK);
+ cell.setBlank();
assertEquals(CellType.BLANK, cell.getCellType());
assertFalse(cell.isPartOfArrayFormulaGroup());
}
@Test(expected = IllegalStateException.class)
- public void setCellType_BLANK_throwsISE_ifCellIsPartOfAnArrayFormulaGroupContainingOtherCells() {
+ public void setBlank_throwsISE_ifCellIsPartOfAnArrayFormulaGroupContainingOtherCells() {
Cell cell = getInstance();
cell.getSheet().setArrayFormula("1", CellRangeAddress.valueOf("A1:B1"));
cell.setCellValue("foo");
- cell.setCellType(CellType.BLANK);
+ cell.setBlank();
}
@Test(expected = IllegalStateException.class)