Skip to content

Commit 6b824e2

Browse files
loolygitee-org
authored andcommitted
!1002 添加writeCellValue的重载,以支持isHeader
Merge pull request !1002 from hower/v5-dev
2 parents dad1790 + 64f575f commit 6b824e2

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

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

+32-5
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
/**
@@ -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)