|
|
@ -72,7 +72,7 @@ public class FillStyleDataTest { |
|
|
|
Assert.assertTrue(cell0.getCellStyle().getFont().getBold()); |
|
|
|
Assert.assertTrue(cell0.getCellStyle().getFont().getBold()); |
|
|
|
|
|
|
|
|
|
|
|
XSSFCell cell1 = row.getCell(1); |
|
|
|
XSSFCell cell1 = row.getCell(1); |
|
|
|
Assert.assertEquals("5", cell1.getStringCellValue()); |
|
|
|
Assert.assertEquals("5.2", cell1.getStringCellValue()); |
|
|
|
Assert.assertEquals(0, cell1.getCellStyle().getDataFormat()); |
|
|
|
Assert.assertEquals(0, cell1.getCellStyle().getDataFormat()); |
|
|
|
Assert.assertEquals("FF92D050", cell1.getCellStyle().getFillForegroundColorColor().getARGBHex()); |
|
|
|
Assert.assertEquals("FF92D050", cell1.getCellStyle().getFillForegroundColorColor().getARGBHex()); |
|
|
|
Assert.assertEquals("FF4BACC6", cell1.getCellStyle().getFont().getXSSFColor().getARGBHex()); |
|
|
|
Assert.assertEquals("FF4BACC6", cell1.getCellStyle().getFont().getXSSFColor().getARGBHex()); |
|
|
@ -86,7 +86,7 @@ public class FillStyleDataTest { |
|
|
|
Assert.assertTrue(cell2.getCellStyle().getFont().getBold()); |
|
|
|
Assert.assertTrue(cell2.getCellStyle().getFont().getBold()); |
|
|
|
|
|
|
|
|
|
|
|
XSSFCell cell3 = row.getCell(3); |
|
|
|
XSSFCell cell3 = row.getCell(3); |
|
|
|
Assert.assertEquals("张三今年5岁了", cell3.getStringCellValue()); |
|
|
|
Assert.assertEquals("张三今年5.2岁了", cell3.getStringCellValue()); |
|
|
|
Assert.assertEquals(0, cell3.getCellStyle().getDataFormat()); |
|
|
|
Assert.assertEquals(0, cell3.getCellStyle().getDataFormat()); |
|
|
|
Assert.assertEquals("FFFF0000", cell3.getCellStyle().getFillForegroundColorColor().getARGBHex()); |
|
|
|
Assert.assertEquals("FFFF0000", cell3.getCellStyle().getFillForegroundColorColor().getARGBHex()); |
|
|
|
Assert.assertEquals("FFEEECE1", cell3.getCellStyle().getFont().getXSSFColor().getARGBHex()); |
|
|
|
Assert.assertEquals("FFEEECE1", cell3.getCellStyle().getFont().getXSSFColor().getARGBHex()); |
|
|
@ -126,7 +126,7 @@ public class FillStyleDataTest { |
|
|
|
Assert.assertTrue(cell0.getCellStyle().getFont(workbook).getBold()); |
|
|
|
Assert.assertTrue(cell0.getCellStyle().getFont(workbook).getBold()); |
|
|
|
|
|
|
|
|
|
|
|
HSSFCell cell1 = row.getCell(1); |
|
|
|
HSSFCell cell1 = row.getCell(1); |
|
|
|
Assert.assertEquals("5", cell1.getStringCellValue()); |
|
|
|
Assert.assertEquals("5.2", cell1.getStringCellValue()); |
|
|
|
Assert.assertEquals(0, cell1.getCellStyle().getDataFormat()); |
|
|
|
Assert.assertEquals(0, cell1.getCellStyle().getDataFormat()); |
|
|
|
Assert.assertEquals("9999:CCCC:0", cell1.getCellStyle().getFillForegroundColorColor().getHexString()); |
|
|
|
Assert.assertEquals("9999:CCCC:0", cell1.getCellStyle().getFillForegroundColorColor().getHexString()); |
|
|
|
Assert.assertEquals("0:8080:8080", cell1.getCellStyle().getFont(workbook).getHSSFColor(workbook) |
|
|
|
Assert.assertEquals("0:8080:8080", cell1.getCellStyle().getFont(workbook).getHSSFColor(workbook) |
|
|
@ -141,7 +141,7 @@ public class FillStyleDataTest { |
|
|
|
Assert.assertTrue(cell2.getCellStyle().getFont(workbook).getBold()); |
|
|
|
Assert.assertTrue(cell2.getCellStyle().getFont(workbook).getBold()); |
|
|
|
|
|
|
|
|
|
|
|
HSSFCell cell3 = row.getCell(3); |
|
|
|
HSSFCell cell3 = row.getCell(3); |
|
|
|
Assert.assertEquals("张三今年5岁了", cell3.getStringCellValue()); |
|
|
|
Assert.assertEquals("张三今年5.2岁了", cell3.getStringCellValue()); |
|
|
|
Assert.assertEquals(0, cell3.getCellStyle().getDataFormat()); |
|
|
|
Assert.assertEquals(0, cell3.getCellStyle().getDataFormat()); |
|
|
|
Assert.assertEquals("FFFF:0:0", cell3.getCellStyle().getFillForegroundColorColor().getHexString()); |
|
|
|
Assert.assertEquals("FFFF:0:0", cell3.getCellStyle().getFillForegroundColorColor().getHexString()); |
|
|
|
Assert.assertEquals("FFFF:FFFF:9999", cell3.getCellStyle().getFont(workbook).getHSSFColor(workbook) |
|
|
|
Assert.assertEquals("FFFF:FFFF:9999", cell3.getCellStyle().getFont(workbook).getHSSFColor(workbook) |
|
|
@ -187,7 +187,7 @@ public class FillStyleDataTest { |
|
|
|
Assert.assertTrue(cell0.getCellStyle().getFont().getBold()); |
|
|
|
Assert.assertTrue(cell0.getCellStyle().getFont().getBold()); |
|
|
|
|
|
|
|
|
|
|
|
XSSFCell cell1 = row.getCell(1); |
|
|
|
XSSFCell cell1 = row.getCell(1); |
|
|
|
Assert.assertEquals("5", cell1.getStringCellValue()); |
|
|
|
Assert.assertEquals(5.2, cell1.getNumericCellValue(), 1); |
|
|
|
Assert.assertEquals(0, cell1.getCellStyle().getDataFormat()); |
|
|
|
Assert.assertEquals(0, cell1.getCellStyle().getDataFormat()); |
|
|
|
Assert.assertEquals("FFFF0000", cell1.getCellStyle().getFillForegroundColorColor().getARGBHex()); |
|
|
|
Assert.assertEquals("FFFF0000", cell1.getCellStyle().getFillForegroundColorColor().getARGBHex()); |
|
|
|
Assert.assertEquals("FF800000", cell1.getCellStyle().getFont().getXSSFColor().getARGBHex()); |
|
|
|
Assert.assertEquals("FF800000", cell1.getCellStyle().getFont().getXSSFColor().getARGBHex()); |
|
|
@ -201,28 +201,27 @@ public class FillStyleDataTest { |
|
|
|
Assert.assertTrue(cell2.getCellStyle().getFont().getBold()); |
|
|
|
Assert.assertTrue(cell2.getCellStyle().getFont().getBold()); |
|
|
|
|
|
|
|
|
|
|
|
XSSFCell cell3 = row.getCell(3); |
|
|
|
XSSFCell cell3 = row.getCell(3); |
|
|
|
Assert.assertEquals("张三今年5岁了", cell3.getStringCellValue()); |
|
|
|
Assert.assertEquals("张三今年5.2岁了", cell3.getStringCellValue()); |
|
|
|
Assert.assertEquals(0, cell3.getCellStyle().getDataFormat()); |
|
|
|
Assert.assertEquals(0, cell3.getCellStyle().getDataFormat()); |
|
|
|
Assert.assertEquals("FF0000FF", cell3.getCellStyle().getFillForegroundColorColor().getARGBHex()); |
|
|
|
Assert.assertEquals("FFFF0000", cell3.getCellStyle().getFillForegroundColorColor().getARGBHex()); |
|
|
|
Assert.assertEquals("FF000080", cell3.getCellStyle().getFont().getXSSFColor().getARGBHex()); |
|
|
|
Assert.assertEquals("FFEEECE1", cell3.getCellStyle().getFont().getXSSFColor().getARGBHex()); |
|
|
|
Assert.assertTrue(cell3.getCellStyle().getFont().getBold()); |
|
|
|
Assert.assertTrue(cell3.getCellStyle().getFont().getBold()); |
|
|
|
|
|
|
|
|
|
|
|
XSSFCell cell4 = row.getCell(4); |
|
|
|
XSSFCell cell4 = row.getCell(4); |
|
|
|
Assert.assertEquals("{.name}忽略,张三", cell4.getStringCellValue()); |
|
|
|
Assert.assertEquals("{.name}忽略,张三", cell4.getStringCellValue()); |
|
|
|
Assert.assertEquals(0, cell4.getCellStyle().getDataFormat()); |
|
|
|
Assert.assertEquals(0, cell4.getCellStyle().getDataFormat()); |
|
|
|
Assert.assertEquals("FFFFFF00", cell4.getCellStyle().getFillForegroundColorColor().getARGBHex()); |
|
|
|
Assert.assertEquals("FFC00000", cell4.getCellStyle().getFillForegroundColorColor().getARGBHex()); |
|
|
|
Assert.assertEquals("FF808000", cell4.getCellStyle().getFont().getXSSFColor().getARGBHex()); |
|
|
|
Assert.assertEquals("FF000000", cell4.getCellStyle().getFont().getXSSFColor().getARGBHex()); |
|
|
|
Assert.assertTrue(cell4.getCellStyle().getFont().getBold()); |
|
|
|
Assert.assertFalse(cell4.getCellStyle().getFont().getBold()); |
|
|
|
|
|
|
|
|
|
|
|
XSSFCell cell5 = row.getCell(5); |
|
|
|
XSSFCell cell5 = row.getCell(5); |
|
|
|
Assert.assertEquals("空", cell5.getStringCellValue()); |
|
|
|
Assert.assertEquals("空", cell5.getStringCellValue()); |
|
|
|
Assert.assertEquals(0, cell5.getCellStyle().getDataFormat()); |
|
|
|
Assert.assertEquals(0, cell5.getCellStyle().getDataFormat()); |
|
|
|
Assert.assertEquals("FF008080", cell5.getCellStyle().getFillForegroundColorColor().getARGBHex()); |
|
|
|
Assert.assertEquals("FFF79646", cell5.getCellStyle().getFillForegroundColorColor().getARGBHex()); |
|
|
|
Assert.assertEquals("FF003366", cell5.getCellStyle().getFont().getXSSFColor().getARGBHex()); |
|
|
|
Assert.assertEquals("FF8064A2", cell5.getCellStyle().getFont().getXSSFColor().getARGBHex()); |
|
|
|
Assert.assertTrue(cell5.getCellStyle().getFont().getBold()); |
|
|
|
Assert.assertFalse(cell5.getCellStyle().getFont().getBold()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void t12FillStyleHandler03() throws Exception { |
|
|
|
public void t12FillStyleHandler03() throws Exception { |
|
|
|
fillStyleHandler(fileStyleHandler03, fileStyleTemplate03); |
|
|
|
fillStyleHandler(fileStyleHandler03, fileStyleTemplate03); |
|
|
@ -242,7 +241,7 @@ public class FillStyleDataTest { |
|
|
|
Assert.assertTrue(cell0.getCellStyle().getFont(workbook).getBold()); |
|
|
|
Assert.assertTrue(cell0.getCellStyle().getFont(workbook).getBold()); |
|
|
|
|
|
|
|
|
|
|
|
HSSFCell cell1 = row.getCell(1); |
|
|
|
HSSFCell cell1 = row.getCell(1); |
|
|
|
Assert.assertEquals("5", cell1.getStringCellValue()); |
|
|
|
Assert.assertEquals(5.2, cell1.getNumericCellValue(), 1); |
|
|
|
Assert.assertEquals(0, cell1.getCellStyle().getDataFormat()); |
|
|
|
Assert.assertEquals(0, cell1.getCellStyle().getDataFormat()); |
|
|
|
Assert.assertEquals("FFFF:0:0", cell1.getCellStyle().getFillForegroundColorColor().getHexString()); |
|
|
|
Assert.assertEquals("FFFF:0:0", cell1.getCellStyle().getFillForegroundColorColor().getHexString()); |
|
|
|
Assert.assertEquals("8080:0:0", cell1.getCellStyle().getFont(workbook).getHSSFColor(workbook) |
|
|
|
Assert.assertEquals("8080:0:0", cell1.getCellStyle().getFont(workbook).getHSSFColor(workbook) |
|
|
@ -257,32 +256,32 @@ public class FillStyleDataTest { |
|
|
|
Assert.assertTrue(cell2.getCellStyle().getFont(workbook).getBold()); |
|
|
|
Assert.assertTrue(cell2.getCellStyle().getFont(workbook).getBold()); |
|
|
|
|
|
|
|
|
|
|
|
HSSFCell cell3 = row.getCell(3); |
|
|
|
HSSFCell cell3 = row.getCell(3); |
|
|
|
Assert.assertEquals("张三今年5岁了", cell3.getStringCellValue()); |
|
|
|
Assert.assertEquals("张三今年5.2岁了", cell3.getStringCellValue()); |
|
|
|
Assert.assertEquals(0, cell3.getCellStyle().getDataFormat()); |
|
|
|
Assert.assertEquals(0, cell3.getCellStyle().getDataFormat()); |
|
|
|
Assert.assertEquals("0:0:FFFF", cell3.getCellStyle().getFillForegroundColorColor().getHexString()); |
|
|
|
Assert.assertEquals("FFFF:0:0", cell3.getCellStyle().getFillForegroundColorColor().getHexString()); |
|
|
|
Assert.assertEquals("0:0:8080", cell3.getCellStyle().getFont(workbook).getHSSFColor(workbook) |
|
|
|
Assert.assertEquals("FFFF:FFFF:9999", cell3.getCellStyle().getFont(workbook).getHSSFColor(workbook) |
|
|
|
.getHexString()); |
|
|
|
.getHexString()); |
|
|
|
Assert.assertTrue(cell3.getCellStyle().getFont(workbook).getBold()); |
|
|
|
Assert.assertTrue(cell3.getCellStyle().getFont(workbook).getBold()); |
|
|
|
|
|
|
|
|
|
|
|
HSSFCell cell4 = row.getCell(4); |
|
|
|
HSSFCell cell4 = row.getCell(4); |
|
|
|
Assert.assertEquals("{.name}忽略,张三", cell4.getStringCellValue()); |
|
|
|
Assert.assertEquals("{.name}忽略,张三", cell4.getStringCellValue()); |
|
|
|
Assert.assertEquals(0, cell4.getCellStyle().getDataFormat()); |
|
|
|
Assert.assertEquals(0, cell4.getCellStyle().getDataFormat()); |
|
|
|
Assert.assertEquals("FFFF:FFFF:0", cell4.getCellStyle().getFillForegroundColorColor().getHexString()); |
|
|
|
Assert.assertEquals("9999:3333:0", cell4.getCellStyle().getFillForegroundColorColor().getHexString()); |
|
|
|
Assert.assertEquals("8080:8080:0", cell4.getCellStyle().getFont(workbook).getHSSFColor(workbook) |
|
|
|
Assert.assertEquals("3333:3333:3333", cell4.getCellStyle().getFont(workbook).getHSSFColor(workbook) |
|
|
|
.getHexString()); |
|
|
|
.getHexString()); |
|
|
|
Assert.assertTrue(cell4.getCellStyle().getFont(workbook).getBold()); |
|
|
|
Assert.assertFalse(cell4.getCellStyle().getFont(workbook).getBold()); |
|
|
|
|
|
|
|
|
|
|
|
HSSFCell cell5 = row.getCell(5); |
|
|
|
HSSFCell cell5 = row.getCell(5); |
|
|
|
Assert.assertEquals("空", cell5.getStringCellValue()); |
|
|
|
Assert.assertEquals("空", cell5.getStringCellValue()); |
|
|
|
Assert.assertEquals(0, cell5.getCellStyle().getDataFormat()); |
|
|
|
Assert.assertEquals(0, cell5.getCellStyle().getDataFormat()); |
|
|
|
Assert.assertEquals("0:8080:8080", cell5.getCellStyle().getFillForegroundColorColor().getHexString()); |
|
|
|
Assert.assertEquals("9999:3333:0", cell5.getCellStyle().getFillForegroundColorColor().getHexString()); |
|
|
|
Assert.assertEquals("0:3333:6666", cell5.getCellStyle().getFont(workbook).getHSSFColor(workbook) |
|
|
|
Assert.assertEquals("CCCC:9999:FFFF", cell5.getCellStyle().getFont(workbook).getHSSFColor(workbook) |
|
|
|
.getHexString()); |
|
|
|
.getHexString()); |
|
|
|
Assert.assertTrue(cell5.getCellStyle().getFont(workbook).getBold()); |
|
|
|
Assert.assertFalse(cell5.getCellStyle().getFont(workbook).getBold()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void fillStyleHandler(File file, File template) throws Exception { |
|
|
|
private void fillStyleHandler(File file, File template) throws Exception { |
|
|
|
EasyExcel.write(file, FillData.class).withTemplate(template).sheet() |
|
|
|
EasyExcel.write(file, FillStyleData.class).withTemplate(template).sheet() |
|
|
|
.registerWriteHandler(new AbstractVerticalCellStyleStrategy() { |
|
|
|
.registerWriteHandler(new AbstractVerticalCellStyleStrategy() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|