Skip to content

Commit

Permalink
注释小调整。
Browse files Browse the repository at this point in the history
  • Loading branch information
wangliang181230 committed Jul 10, 2024
1 parent 96f5129 commit 8d43945
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@

/**
* 相同单元格合并定义
*
* @since 0.7.8
*/
String[] mergeSameCells() default {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public class ExcelMapping implements Serializable {
/**
* 相同单元格合并
* 要注意多组合并的字段名不能相同
*
* @since 0.7.8
*/
private String[] mergeSameCells;

Expand Down Expand Up @@ -214,10 +216,16 @@ public void setCellMappingList(List<ExcelCellMapping> cellMappingList) {
this.cellMappingList = cellMappingList;
}

/**
* @since 0.7.8
*/
public String[] getMergeSameCells() {
return mergeSameCells;
}

/**
* @since 0.7.8
*/
public void setMergeSameCells(String[] mergeSameCells) {
this.mergeSameCells = mergeSameCells;
}
Expand Down Expand Up @@ -247,6 +255,9 @@ public List<IListToExcelHook> getToExcelHookList() {

//endregion

/**
* @since 0.7.8
*/
public ExcelCellMapping getCellMappingByFieldName(String fieldName) {
for (ExcelCellMapping cellMapping : cellMappingList) {
if (cellMapping.getColumn() != null && cellMapping.getColumn().equals(fieldName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ public static void createDataRows(Sheet sheet, List<?> dataList, ExcelMapping ma
}
}

/**
* @since 0.7.8
*/
public static void mergeSameCells(Sheet sheet, ExcelMapping mapping) {
if (ArrayUtils.isEmpty(mapping.getMergeSameCells())) {
return; // 未定义需要合并的单元格
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ private static Sheet generateSheet(Workbook book, List<?> dataList, ExcelMapping
if (CollectionUtils.isNotEmpty(dataList)) {
// 创建数据行
ExcelRowUtils.createDataRows(sheet, dataList, mapping);
// 合并单元格
// 合并单元格 @since 0.7.8
ExcelRowUtils.mergeSameCells(sheet, mapping);
}

Expand Down

0 comments on commit 8d43945

Please sign in to comment.