|
|
@ -2,10 +2,12 @@ package com.ruoyi.common.core.utils.poi;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
import java.lang.reflect.ParameterizedType;
|
|
|
|
import java.lang.reflect.ParameterizedType;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
import java.text.DecimalFormat;
|
|
|
|
import java.text.DecimalFormat;
|
|
|
|
import java.time.LocalDate;
|
|
|
|
import java.time.LocalDate;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
@ -455,6 +457,11 @@ public class ExcelUtil<T>
|
|
|
|
public void exportExcel(HttpServletResponse response, List<T> list, String sheetName, String title)
|
|
|
|
public void exportExcel(HttpServletResponse response, List<T> list, String sheetName, String title)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
response.addHeader("Content-Disposition", "attachment;FileName=" + URLEncoder.encode(title,"utf-8"));
|
|
|
|
|
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
|
|
|
}
|
|
|
|
response.setCharacterEncoding("utf-8");
|
|
|
|
response.setCharacterEncoding("utf-8");
|
|
|
|
this.init(list, sheetName, title, Type.EXPORT);
|
|
|
|
this.init(list, sheetName, title, Type.EXPORT);
|
|
|
|
exportExcel(response);
|
|
|
|
exportExcel(response);
|
|
|
@ -681,6 +688,7 @@ public class ExcelUtil<T>
|
|
|
|
if (!headerStyles.containsKey(key))
|
|
|
|
if (!headerStyles.containsKey(key))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CellStyle style = wb.createCellStyle();
|
|
|
|
CellStyle style = wb.createCellStyle();
|
|
|
|
|
|
|
|
style = wb.createCellStyle();
|
|
|
|
style.cloneStyleFrom(styles.get("data"));
|
|
|
|
style.cloneStyleFrom(styles.get("data"));
|
|
|
|
style.setAlignment(HorizontalAlignment.CENTER);
|
|
|
|
style.setAlignment(HorizontalAlignment.CENTER);
|
|
|
|
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
|
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
@ -714,6 +722,7 @@ public class ExcelUtil<T>
|
|
|
|
if (!styles.containsKey(key))
|
|
|
|
if (!styles.containsKey(key))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CellStyle style = wb.createCellStyle();
|
|
|
|
CellStyle style = wb.createCellStyle();
|
|
|
|
|
|
|
|
style = wb.createCellStyle();
|
|
|
|
style.setAlignment(excel.align());
|
|
|
|
style.setAlignment(excel.align());
|
|
|
|
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
|
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
|
style.setBorderRight(BorderStyle.THIN);
|
|
|
|
style.setBorderRight(BorderStyle.THIN);
|
|
|
|