*/
void setCellType(CellType cellType);
+ /**
+ * Removes formula and value from the cell, and sets its type to {@link CellType#BLANK}.
+ * Preserves comments and hyperlinks.
+ * While {@link #setCellType(CellType)} exists, is an alias for {@code setCellType(CellType.BLANK)}.
+ */
+ void setBlank();
+
/**
* Return the cell type.
*
setCellTypeImpl(cellType);
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setBlank() {
+ setCellType(CellType.BLANK);
+ }
+
/**
* Implementation-specific logic
* @param cellType new cell type. Guaranteed non-null, not _NONE.
* Blanks this cell. Blank cells have no formula or value but may have styling.
* This method erases all the data previously associated with this cell.
*/
- private void setBlank(){
+ private void setBlankPrivate(){
CTCell blank = CTCell.Factory.newInstance();
blank.setR(_cell.getR());
if(_cell.isSetS()) {
}
break;
case BLANK:
- setBlank();
+ setBlankPrivate();
break;
case BOOLEAN:
String newVal = convertCellValueToBoolean() ? TRUE_AS_STRING : FALSE_AS_STRING;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import static org.mockito.Mockito.doCallRealMethod;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.TimeZone;
-import java.util.function.Consumer;
import org.apache.poi.common.usermodel.HyperlinkType;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.ITestDataProvider;
import org.apache.poi.ss.SpreadsheetVersion;
-import org.apache.poi.ss.formula.FormulaParseException;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.LocaleUtil;
import org.junit.Test;
assertTrue(cell.getBooleanCellValue());
}
+ @Test
+ public final void setBlank_delegatesTo_setCellType_BLANK() {
+ Cell cell = mock(CellBase.class);
+ doCallRealMethod().when(cell).setBlank();
+
+ cell.setBlank();
+
+ verify(cell).setCellType(CellType.BLANK);
+ }
+
private Cell getInstance() {
return _testDataProvider.createWorkbook().createSheet().createRow(0).createCell(0);
}