Skip to content

Commit 64f575f

Browse files
committed
添加writeCellValue的重载,以支持isHeader
1 parent 4323a98 commit 64f575f

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

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

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,30 +1097,57 @@ public ExcelWriter writeRow(Iterable<?> rowData) {
10971097
}
10981098

10991099
/**
1100-
* 给指定单元格赋值,使用默认单元格样式
1100+
* 给指定单元格赋值,使用默认单元格样式,默认不是Header
11011101
*
11021102
* @param locationRef 单元格地址标识符,例如A11,B5
11031103
* @param value 值
11041104
* @return this
11051105
* @since 5.1.4
11061106
*/
11071107
public ExcelWriter writeCellValue(String locationRef, Object value) {
1108-
final CellLocation cellLocation = ExcelUtil.toLocation(locationRef);
1109-
return writeCellValue(cellLocation.getX(), cellLocation.getY(), value);
1108+
return writeCellValue(locationRef, value, false);
11101109
}
11111110

11121111
/**
11131112
* 给指定单元格赋值,使用默认单元格样式
11141113
*
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) {
1121+
final CellLocation cellLocation = ExcelUtil.toLocation(locationRef);
1122+
return writeCellValue(cellLocation.getX(), cellLocation.getY(), value, isHeader);
1123+
}
1124+
1125+
/**
1126+
* 给指定单元格赋值,使用默认单元格样式,默认不是Header
1127+
*
11151128
* @param x X坐标,从0计数,即列号
11161129
* @param y Y坐标,从0计数,即行号
11171130
* @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 isHeader 是否为Header
1144+
* @param value 值
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)