mirror of https://github.com/apache/poi.git
add test case
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1906561 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c7822f687a
commit
786af03e67
|
@ -30,12 +30,14 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
|
||||
import org.apache.poi.hssf.HSSFITestDataProvider;
|
||||
import org.apache.poi.hssf.HSSFTestDataSamples;
|
||||
import org.apache.poi.hssf.model.InternalSheet;
|
||||
import org.apache.poi.hssf.record.DBCellRecord;
|
||||
import org.apache.poi.hssf.record.FormulaRecord;
|
||||
import org.apache.poi.hssf.record.StringRecord;
|
||||
import org.apache.poi.hssf.util.HSSFColor;
|
||||
import org.apache.poi.ss.usermodel.BaseTestCell;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
|
@ -415,4 +417,28 @@ final class TestHSSFCell extends BaseTestCell {
|
|||
assertThrows(IllegalStateException.class, cell::getErrorCellValue);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void setFillForegroundColor() throws IOException {
|
||||
try (
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream()
|
||||
) {
|
||||
Cell cell = wb.createSheet().createRow(0).createCell(0);
|
||||
HSSFCellStyle cellStyle = wb.createCellStyle();
|
||||
HSSFPalette palette = wb.getCustomPalette();
|
||||
palette.setColorAtIndex((short) 1, (byte) 60, (byte) 120, (byte) 216);
|
||||
HSSFColor color = palette.findSimilarColor(60, 120, 216);
|
||||
cellStyle.setFillForegroundColor(color);
|
||||
cell.setCellStyle(cellStyle);
|
||||
assertEquals(color, cellStyle.getFillForegroundColorColor());
|
||||
wb.write(bos);
|
||||
|
||||
try (HSSFWorkbook wb2 = new HSSFWorkbook(bos.toInputStream())) {
|
||||
HSSFSheet sheet = wb2.getSheetAt(0);
|
||||
HSSFCellStyle savedStyle = sheet.getRow(0).getCell(0).getCellStyle();
|
||||
assertEquals(color, savedStyle.getFillForegroundColorColor());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue