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

--- Comment #13 from XL <x...@ijoinery.com> ---
Thank you very much for your correction in r1903816.
I confirm that my previous JUnit test now works.

But when the CellUtil class of r1903816 is used,
the new following issue occurs.

If a cell style has a fill foreground color that is initially NOT null,
then the color remains NOT null after calling CellUtil.setCellStyleProperty.

The issue can be reproduced by executing the new following JUnit test,
in which the last assertNull call throws an error.



package test;

import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;

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.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 org.junit.jupiter.api.Test;

import java.io.IOException;

public class CellUtilTest {

  @Test
  public void testSetCellStyleProperty() 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("AAAAAA"));

      assertNull(cell.getCellStyle().getFillForegroundColorColor());

      CellUtil.setCellStyleProperty(
        cell, CellUtil.FILL_FOREGROUND_COLOR_COLOR, color);

      assertNotNull(cell.getCellStyle().getFillForegroundColorColor());

      CellUtil.setCellStyleProperty(
        cell, CellUtil.FILL_FOREGROUND_COLOR_COLOR, null);

      assertNull(cell.getCellStyle().getFillForegroundColorColor());
    }
  }
}

-- 
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