Skip to content

Commit c07a3d9

Browse files
committed
添加writeCellValue的重载,以支持isHeader
1 parent 2e88e74 commit c07a3d9

1 file changed

Lines changed: 33 additions & 6 deletions

File tree

hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelWriter.java

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ public ExcelWriter writeImg(File imgFile, int dx1, int dy1, int dx2, int dy2, in
889889
public ExcelWriter writeImg(File imgFile, int imgType, int dx1, int dy1, int dx2,
890890
int dy2, int col1, int row1, int col2, int row2) {
891891
return writeImg(FileUtil.readBytes(imgFile), imgType, dx1,
892-
dy1, dx2, dy2, col1, row1, col2, row2);
892+
dy1, dx2, dy2, col1, row1, col2, row2);
893893
}
894894

895895
/**
@@ -1105,22 +1105,49 @@ public ExcelWriter writeRow(Iterable<?> rowData) {
11051105
* @since 5.1.4
11061106
*/
11071107
public ExcelWriter writeCellValue(String locationRef, Object value) {
1108+
return writeCellValue(locationRef, value, false);
1109+
}
1110+
1111+
/**
1112+
* 给指定单元格赋值,使用默认单元格样式
1113+
*
1114+
* @param locationRef 单元格地址标识符,例如A11,B5
1115+
* @param value 值
1116+
* @param isHeader 是否为Header
1117+
* @return this
1118+
* @since 5.1.4
1119+
*/
1120+
public ExcelWriter writeCellValue(String locationRef, Object value, boolean isHeader) {
11081121
final CellLocation cellLocation = ExcelUtil.toLocation(locationRef);
1109-
return writeCellValue(cellLocation.getX(), cellLocation.getY(), value);
1122+
return writeCellValue(cellLocation.getX(), cellLocation.getY(), value, isHeader);
11101123
}
11111124

11121125
/**
11131126
* 给指定单元格赋值,使用默认单元格样式
11141127
*
1115-
* @param x X坐标,从0计数,即列号
1116-
* @param y Y坐标,从0计数,即行号
1117-
* @param value 值
1128+
* @param x X坐标,从0计数,即列号
1129+
* @param y Y坐标,从0计数,即行号
1130+
* @param value
11181131
* @return this
11191132
* @since 4.0.2
11201133
*/
11211134
public ExcelWriter writeCellValue(int x, int y, Object value) {
1135+
return writeCellValue(x, y, value, false);
1136+
}
1137+
1138+
/**
1139+
* 给指定单元格赋值,使用默认单元格样式
1140+
*
1141+
* @param x X坐标,从0计数,即列号
1142+
* @param y Y坐标,从0计数,即行号
1143+
* @param value 值
1144+
* @param isHeader 是否为Header
1145+
* @return this
1146+
* @since 4.0.2
1147+
*/
1148+
public ExcelWriter writeCellValue(int x, int y, Object value, boolean isHeader) {
11221149
final Cell cell = getOrCreateCell(x, y);
1123-
CellUtil.setCellValue(cell, value, this.styleSet, false);
1150+
CellUtil.setCellValue(cell, value, this.styleSet, isHeader);
11241151
return this;
11251152
}
11261153

0 commit comments

Comments
 (0)