|
@@ -10,8 +10,6 @@ import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.exception.CommonException;
|
|
|
import com.diagbot.service.impl.ExcelExportStylerUserImpl;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.apache.poi.hssf.usermodel.HSSFSheet;
|
|
|
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
@@ -45,6 +43,11 @@ public class ExcelUtils {
|
|
|
userExport(list, pojoClass, fileName, response, exportParams);
|
|
|
}
|
|
|
|
|
|
+ public static void exportExcel(List<?> list, String title, String sheetName, Class<?> pojoClass, String fileName,
|
|
|
+ HttpServletResponse response, float height) {
|
|
|
+ userExport2(list, pojoClass, fileName, response, new ExportParams(title, sheetName), height);
|
|
|
+ }
|
|
|
+
|
|
|
public static void exportExcel(List<?> list, String title, String sheetName, Class<?> pojoClass, String fileName,
|
|
|
HttpServletResponse response) {
|
|
|
defaultExport(list, pojoClass, fileName, response, new ExportParams(title, sheetName));
|
|
@@ -64,13 +67,13 @@ public class ExcelUtils {
|
|
|
}
|
|
|
|
|
|
private static void userExport(List<?> list, Class<?> pojoClass, String fileName, HttpServletResponse response,
|
|
|
- ExportParams exportParams) {
|
|
|
+ ExportParams exportParams) {
|
|
|
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, pojoClass, list);
|
|
|
if (workbook != null) {
|
|
|
Sheet sheet = workbook.getSheetAt(0);
|
|
|
//列宽设置
|
|
|
- sheet.setColumnWidth(8, 256*20);
|
|
|
- sheet.setColumnWidth(9, 256*50);
|
|
|
+ sheet.setColumnWidth(8, 256 * 20);
|
|
|
+ sheet.setColumnWidth(9, 256 * 50);
|
|
|
int rowNum = sheet.getLastRowNum();
|
|
|
Row row = sheet.getRow(0);
|
|
|
for (int i = 1; i <= rowNum; i++) {
|
|
@@ -81,6 +84,21 @@ public class ExcelUtils {
|
|
|
downLoadExcel(fileName, response, workbook);
|
|
|
}
|
|
|
|
|
|
+ private static void userExport2(List<?> list, Class<?> pojoClass, String fileName, HttpServletResponse response,
|
|
|
+ ExportParams exportParams, float height) {
|
|
|
+ Workbook workbook = ExcelExportUtil.exportExcel(exportParams, pojoClass, list);
|
|
|
+ if (workbook != null) {
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+ int rowNum = sheet.getLastRowNum();
|
|
|
+ Row row = sheet.getRow(0);
|
|
|
+ for (int i = 1; i <= rowNum; i++) {
|
|
|
+ row = sheet.getRow(i);
|
|
|
+ row.setHeightInPoints(height);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ downLoadExcel(fileName, response, workbook);
|
|
|
+ }
|
|
|
+
|
|
|
private static void downLoadExcel(String fileName, HttpServletResponse response, Workbook workbook) {
|
|
|
try {
|
|
|
response.setCharacterEncoding("UTF-8");
|