Commit 2dcdf475 authored by yanzg's avatar yanzg

接口文档的支持

parent 7e9a4574
...@@ -301,7 +301,7 @@ public class ExcelConsole<T extends Object> implements DbRow<T> { ...@@ -301,7 +301,7 @@ public class ExcelConsole<T extends Object> implements DbRow<T> {
if (column.isMerger()) { if (column.isMerger()) {
ExcelMergerData mergerData = mergerGroupData.get(column.getMegerGroup()); ExcelMergerData mergerData = mergerGroupData.get(column.getMegerGroup());
// 判断是否需要合并历史记录 // 判断是否需要合并历史记录
if (mergerData.getRowCell() > 1) { if (mergerData.isMergerFlag()) {
// 合并历史记录单元格 // 合并历史记录单元格
mergerData(mergerData, columnPos); mergerData(mergerData, columnPos);
} }
...@@ -320,6 +320,7 @@ public class ExcelConsole<T extends Object> implements DbRow<T> { ...@@ -320,6 +320,7 @@ public class ExcelConsole<T extends Object> implements DbRow<T> {
private void mergerData(ExcelMergerData mergerColumn, int columnPos) { private void mergerData(ExcelMergerData mergerColumn, int columnPos) {
int rowStart = mergerColumn.getRowIndex(); int rowStart = mergerColumn.getRowIndex();
int rowEnd = rowStart + mergerColumn.getRowCell() - 1; int rowEnd = rowStart + mergerColumn.getRowCell() - 1;
CellRangeAddress region = new CellRangeAddress(rowStart, rowEnd, columnPos, columnPos); CellRangeAddress region = new CellRangeAddress(rowStart, rowEnd, columnPos, columnPos);
sheet.addMergedRegion(region); sheet.addMergedRegion(region);
...@@ -337,6 +338,15 @@ public class ExcelConsole<T extends Object> implements DbRow<T> { ...@@ -337,6 +338,15 @@ public class ExcelConsole<T extends Object> implements DbRow<T> {
// 合并数据配置 // 合并数据配置
for (int columnPos = 0; columnPos < this.config.getColumns().size(); columnPos++) { for (int columnPos = 0; columnPos < this.config.getColumns().size(); columnPos++) {
ExportColumn column = this.config.getColumns().get(columnPos); ExportColumn column = this.config.getColumns().get(columnPos);
// 判断列是否需要合并
if (column.isMerger()) {
ExcelMergerData mergerData = mergerGroupData.get(column.getMegerGroup());
// 判断是否需要合并历史记录
if (mergerData.isMergerFlag()) {
// 合并历史记录单元格
mergerData(mergerData, columnPos);
}
}
if (column.getWidth() < 1) { if (column.getWidth() < 1) {
sheet.autoSizeColumn(columnPos, true); sheet.autoSizeColumn(columnPos, true);
} else { } else {
......
...@@ -24,6 +24,11 @@ public class ExcelMergerData { ...@@ -24,6 +24,11 @@ public class ExcelMergerData {
*/ */
private int rowCell = 1; private int rowCell = 1;
/**
* 判断是否可以合并
*/
private boolean mergerFlag = false;
/** /**
* 上次合并行号 * 上次合并行号
*/ */
...@@ -50,6 +55,8 @@ public class ExcelMergerData { ...@@ -50,6 +55,8 @@ public class ExcelMergerData {
this.data = nowCellData; this.data = nowCellData;
this.rowIndex = rowIndex; this.rowIndex = rowIndex;
this.rowCell = 1; this.rowCell = 1;
this.mergerFlag = true;
} else { } else {
this.rowCell++; this.rowCell++;
} }
...@@ -59,39 +66,25 @@ public class ExcelMergerData { ...@@ -59,39 +66,25 @@ public class ExcelMergerData {
return data; return data;
} }
public void setData(String data) {
this.data = data;
}
public int getRowIndex() { public int getRowIndex() {
return rowIndex; return rowIndex;
} }
public void setRowIndex(int rowIndex) {
this.rowIndex = rowIndex;
}
public int getRowCell() { public int getRowCell() {
return rowCell; return rowCell;
} }
public void setRowCell(int rowCell) { public boolean isMergerFlag() {
this.rowCell = rowCell; boolean ret = mergerFlag;
mergerFlag = false;
return ret;
} }
public int getRowIndexHistory() { public int getRowIndexHistory() {
return rowIndexHistory; return rowIndexHistory;
} }
public void setRowIndexHistory(int rowIndexHistory) {
this.rowIndexHistory = rowIndexHistory;
}
public int getRowCellHistory() { public int getRowCellHistory() {
return rowCellHistory; return rowCellHistory;
} }
public void setRowCellHistory(int rowCellHistory) {
this.rowCellHistory = rowCellHistory;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment