https://bz.apache.org/bugzilla/show_bug.cgi?id=66052

--- Comment #15 from XL <x...@ijoinery.com> ---
The following issue occurs,
when using the CellUtil class of r1903828.

The issue can be reproduced as follows :
1. Execute the program below, which generates 2 xlsx files.
2. Using the Excel application, open this xlsx file :
BeforeSettingNullFill.xlsx
3. Check that the upper-left cell has a red background.
4. Using the Excel application, open this xlsx file : AfterSettingNullFill.xlsx
5. Check that the upper-left cell has a white background.
6. Double-click in the upper-left cell.
7. Notice that the cell has unexpectedly a black background.
8. Type some text into the upper-left cell.
9. Notice that the text is unexpectedly unreadable because of the background.




package test;

import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellUtil;
import org.apache.poi.xssf.usermodel.XSSFColor;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.LinkedHashMap;
import java.util.Map;

public class CellUtilProgram {

  public static void main(String[] args) throws IOException, DecoderException {

    try (Workbook workbook = new XSSFWorkbook()) {

      final Sheet sheet = workbook.createSheet("Sheet");
      final Row row = sheet.createRow(0);
      final Cell cell = row.createCell(0);
      final XSSFColor color = new XSSFColor(Hex.decodeHex("FF0000"));

      {
        final Map<String, Object> properties =
          new LinkedHashMap<String, Object>();

        properties.put(CellUtil.FILL_FOREGROUND_COLOR_COLOR, color);
        properties.put(CellUtil.FILL_PATTERN,
FillPatternType.SOLID_FOREGROUND);

        CellUtil.setCellStyleProperties(cell, properties);
      }

      try (OutputStream stream =
        new FileOutputStream("BeforeSettingNullFill.xlsx")) {

        workbook.write(stream);
      }

      {
        final Map<String, Object> properties =
          new LinkedHashMap<String, Object>();

        properties.put(CellUtil.FILL_FOREGROUND_COLOR_COLOR, null);
        properties.put(CellUtil.FILL_PATTERN, FillPatternType.NO_FILL);

        CellUtil.setCellStyleProperties(cell, properties);
      }

      try (OutputStream stream =
        new FileOutputStream("AfterSettingNullFill.xlsx")) {

        workbook.write(stream);
      }
    }
  }
}

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org

Reply via email to