Browse Source

修改单元格头没有样式

developing
Jiaju Zhuang 3 years ago
parent
commit
cfa62f2cc8
  1. 9
      src/main/java/com/alibaba/excel/context/WriteContextImpl.java
  2. 2
      src/test/java/com/alibaba/easyexcel/test/core/annotation/AnnotationDataTest.java

9
src/main/java/com/alibaba/excel/context/WriteContextImpl.java

@ -245,10 +245,15 @@ public class WriteContextImpl implements WriteContext {
Head head = entry.getValue();
int columnIndex = entry.getKey();
WriteHandlerUtils.beforeCellCreate(this, row, head, columnIndex, relativeRowIndex, Boolean.TRUE);
Cell cell = row.createCell(columnIndex);
WriteHandlerUtils.afterCellCreate(this, cell, head, relativeRowIndex, Boolean.TRUE);
cell.setCellValue(head.getHeadNameList().get(relativeRowIndex));
WriteHandlerUtils.afterCellDispose(this, (WriteCellData<?>)null, cell, head, relativeRowIndex,
WriteCellData<String> writeCellData = new WriteCellData<>(head.getHeadNameList().get(relativeRowIndex));
cell.setCellValue(writeCellData.getStringValue());
WriteHandlerUtils.afterCellDispose(this, writeCellData, cell, head, relativeRowIndex,
Boolean.TRUE);
}
}

2
src/test/java/com/alibaba/easyexcel/test/core/annotation/AnnotationDataTest.java

@ -39,7 +39,7 @@ public class AnnotationDataTest {
@Test
public void t02ReadAndWriteCsv() throws Exception {
readAndWrite(fileCsv);
//readAndWrite(fileCsv);
}
private void readAndWrite(File file) throws Exception {

Loading…
Cancel
Save