|
@@ -36,7 +36,7 @@ public class ExcelDownloadSrv {
|
|
|
private final Logger logger = LoggerFactory.getLogger(getClass().getName());
|
|
|
|
|
|
|
|
|
- private final int SHEET_MAX_SIZE = 1;
|
|
|
+ private final int SHEET_MAX_SIZE = 2;
|
|
|
|
|
|
|
|
|
* 下载excel 时 设置 httpServletResponse
|
|
@@ -314,6 +314,7 @@ public class ExcelDownloadSrv {
|
|
|
sheetAmount = listSize / sheetMaxSize + 1;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
|
|
|
for (int i = 0; i < sheetAmount; i++) {
|
|
|
|
|
@@ -327,6 +328,27 @@ public class ExcelDownloadSrv {
|
|
|
sheet.getSettings().setDefaultColumnWidth(20);
|
|
|
sheet.getSettings().setDefaultRowHeight(30 * 20);
|
|
|
|
|
|
+
|
|
|
+ int currentSheetRowAmount = 0;
|
|
|
+ if (listSize < sheetMaxSize * sheetIndex) {
|
|
|
+ currentSheetRowAmount = listSize - sheetMaxSize * currentSheetIndex;
|
|
|
+ } else {
|
|
|
+ currentSheetRowAmount = sheetMaxSize;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (excelStyleMap != null) {
|
|
|
+ for (String column : excelStyleMap.keySet()) {
|
|
|
+
|
|
|
+ int styleColumnWidth = excelStyleMap.getIntValueSafely(column, ExcelStyleMap.STYLE_COLUMN_WIDTH, 0);
|
|
|
+ List<String> columns = new ArrayList<>(data.keySet());
|
|
|
+ for (int j = 0, columnsSize = columns.size(); j < columnsSize; j++) {
|
|
|
+ if (columns.get(j).equals(column)) {
|
|
|
+ sheet.setColumnView(j, styleColumnWidth);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
int firstRow = 0;
|
|
|
|
|
|
int headerColumn = 0;
|
|
@@ -334,17 +356,12 @@ public class ExcelDownloadSrv {
|
|
|
Label label = new Label(headerColumn, firstRow, key, cellFormat);
|
|
|
sheet.addCell(label);
|
|
|
List<String> colData = data.get(key);
|
|
|
-
|
|
|
- int currentSheetRowAmount = 0;
|
|
|
- if (listSize < sheetMaxSize * sheetIndex) {
|
|
|
- currentSheetRowAmount = listSize - sheetMaxSize * currentSheetIndex;
|
|
|
- } else {
|
|
|
- currentSheetRowAmount = sheetMaxSize;
|
|
|
- }
|
|
|
- for (int q = 0; q < currentSheetRowAmount; q++) {
|
|
|
- int e = sheetMaxSize * currentSheetIndex;
|
|
|
- Label lb = new Label(headerColumn, q + 1, Checker.getStringValue(colData.get(e + q)), cellFormat);
|
|
|
- sheet.addCell(lb);
|
|
|
+ if(!Checker.isNone(colData)) {
|
|
|
+ for (int q = 0; q < currentSheetRowAmount; q++) {
|
|
|
+ int e = sheetMaxSize * currentSheetIndex;
|
|
|
+ Label lb = new Label(headerColumn, q + 1, Checker.getStringValue(colData.get(e + q)), cellFormat);
|
|
|
+ sheet.addCell(lb);
|
|
|
+ }
|
|
|
}
|
|
|
headerColumn++;
|
|
|
}
|
|
@@ -354,7 +371,7 @@ public class ExcelDownloadSrv {
|
|
|
for (ExcelCollectPojo pojo : collectList) {
|
|
|
String[] dataArr = pojo.getDataArr();
|
|
|
for (int r = 0, j = dataArr.length; r < j; r++) {
|
|
|
- Label lb2 = new Label(pojo.getCol() + r, pojo.getRow(), dataArr[r], cellFormat);
|
|
|
+ Label lb2 = new Label(pojo.getCol() + r, pojo.getRow() - sheetMaxSize * currentSheetIndex, dataArr[r], cellFormat);
|
|
|
sheet.addCell(lb2);
|
|
|
}
|
|
|
}
|
|
@@ -466,6 +483,13 @@ public class ExcelDownloadSrv {
|
|
|
sheet.getSettings().setDefaultColumnWidth(20);
|
|
|
sheet.getSettings().setDefaultRowHeight(30 * 20);
|
|
|
|
|
|
+
|
|
|
+ int currentSheetRowAmount = 0;
|
|
|
+ if (listSize < sheetMaxSize * sheetIndex) {
|
|
|
+ currentSheetRowAmount = listSize - sheetMaxSize * currentSheetIndex;
|
|
|
+ } else {
|
|
|
+ currentSheetRowAmount = sheetMaxSize;
|
|
|
+ }
|
|
|
|
|
|
if (excelStyleMap != null) {
|
|
|
for (String column : excelStyleMap.keySet()) {
|
|
@@ -483,23 +507,17 @@ public class ExcelDownloadSrv {
|
|
|
int firstRow = 0;
|
|
|
|
|
|
int headerColumn = 0;
|
|
|
-
|
|
|
for (String key : data.keySet()) {
|
|
|
Label label = new Label(headerColumn, firstRow, key, cellFormat);
|
|
|
sheet.addCell(label);
|
|
|
List<String> colData = data.get(key);
|
|
|
-
|
|
|
- int currentSheetRowAmount = 0;
|
|
|
- if (listSize < sheetMaxSize * sheetIndex) {
|
|
|
- currentSheetRowAmount = listSize - sheetMaxSize * currentSheetIndex;
|
|
|
- } else {
|
|
|
- currentSheetRowAmount = sheetMaxSize;
|
|
|
- }
|
|
|
- for (int q = 0; q < currentSheetRowAmount; q++) {
|
|
|
-
|
|
|
- int beforePageAllAmount = sheetMaxSize * currentSheetIndex;
|
|
|
- Label lb = new Label(headerColumn, q + 1, Checker.getStringValue(colData.get(beforePageAllAmount + q)), cellFormat);
|
|
|
- sheet.addCell(lb);
|
|
|
+ if(!Checker.isNone(colData)) {
|
|
|
+ for (int q = 0; q < currentSheetRowAmount; q++) {
|
|
|
+
|
|
|
+ int beforePageAllAmount = sheetMaxSize * currentSheetIndex;
|
|
|
+ Label lb = new Label(headerColumn, q + 1, Checker.getStringValue(colData.get(beforePageAllAmount + q)), cellFormat);
|
|
|
+ sheet.addCell(lb);
|
|
|
+ }
|
|
|
}
|
|
|
headerColumn++;
|
|
|
}
|
|
@@ -507,7 +525,7 @@ public class ExcelDownloadSrv {
|
|
|
if (currentSheetIndex == sheetAmount - 1) {
|
|
|
if (!Checker.isNone(collectList)) {
|
|
|
for (CustomExcelItem item : collectList) {
|
|
|
- sheet.addCell(new Label(item.getColumn(), item.getRow(), item.getContent(), item.getCellFormat() == null ? cellFormat : item.getCellFormat()));
|
|
|
+ sheet.addCell(new Label(item.getColumn(), item.getRow() - sheetMaxSize * currentSheetIndex, item.getContent(), item.getCellFormat() == null ? cellFormat : item.getCellFormat()));
|
|
|
}
|
|
|
}
|
|
|
|