CTFill ct = getCTFill();
CTPatternFill ptrn = ct.getPatternFill();
if(color == null) {
- if(ptrn != null) ptrn.unsetBgColor();
+ if(ptrn != null && ptrn.isSetBgColor()) ptrn.unsetBgColor();
} else {
if(ptrn == null) ptrn = ct.addNewPatternFill();
ptrn.setBgColor(color.getCTColor());
CTPatternFill ptrn = ct.getPatternFill();
if(color == null) {
- if(ptrn != null) ptrn.unsetFgColor();
+ if(ptrn != null && ptrn.isSetFgColor()) ptrn.unsetFgColor();
} else {
if(ptrn == null) ptrn = ct.addNewPatternFill();
ptrn.setFgColor(color.getCTColor());
* @see #setFillForegroundColor(short)
* @param fp fill pattern (set to {@link org.apache.poi.ss.usermodel.CellStyle#SOLID_FOREGROUND} to fill w/foreground color)
*/
- @Override
-public void setFillPattern(short fp) {
+ @Override
+ public void setFillPattern(short fp) {
CTFill ct = getCTFill();
CTPatternFill ptrn = ct.isSetPatternFill() ? ct.getPatternFill() : ct.addNewPatternFill();
if(fp == NO_FILL && ptrn.isSetPatternType()) ptrn.unsetPatternType();
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.CellStyle;
-import org.apache.poi.ss.usermodel.DataFormat;
-import org.apache.poi.ss.usermodel.HorizontalAlignment;
-import org.apache.poi.ss.usermodel.IndexedColors;
-import org.apache.poi.ss.usermodel.Row;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.VerticalAlignment;
-import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.XSSFTestDataSamples;
import org.apache.poi.xssf.model.StylesTable;
import org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder;
cellStyle.setRotation((short)-90);
assertEquals(180, cellStyle.getRotation());
}
+
+ @Test
+ public void bug58996_UsedToWorkIn3_11_ButNotIn3_13() throws IOException {
+ XSSFWorkbook workbook = new XSSFWorkbook();
+
+ XSSFCellStyle cellStyle = workbook.createCellStyle();
+ cellStyle.setFillForegroundColor(null);
+ assertNull(cellStyle.getFillForegroundColorColor());
+
+ cellStyle.setFillBackgroundColor(null);
+ assertNull(cellStyle.getFillBackgroundColorColor());
+
+ cellStyle.setFillPattern(FillPatternType.NO_FILL);
+ assertEquals(FillPatternType.NO_FILL, cellStyle.getFillPatternEnum());
+
+ cellStyle.setBottomBorderColor(null);
+ assertNull(cellStyle.getBottomBorderXSSFColor());
+
+ cellStyle.setTopBorderColor(null);
+ assertNull(cellStyle.getTopBorderXSSFColor());
+
+ cellStyle.setLeftBorderColor(null);
+ assertNull(cellStyle.getLeftBorderXSSFColor());
+
+ cellStyle.setRightBorderColor(null);
+ assertNull(cellStyle.getRightBorderXSSFColor());
+ }
}