Pre Merge pull request !255 from 云飞扬/N/A

pull/255/MERGE
云飞扬 3 years ago committed by Gitee
commit 835bad8bf5
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

@ -2,10 +2,12 @@ package com.ruoyi.common.core.utils.poi;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.text.DecimalFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
@ -255,7 +257,7 @@ public class ExcelUtil<T>
/**
* excellist
*
*
* @param is
* @return
*/
@ -266,7 +268,7 @@ public class ExcelUtil<T>
/**
* excellist
*
*
* @param is
* @param titleNum
* @return
@ -278,7 +280,7 @@ public class ExcelUtil<T>
/**
* excellist
*
*
* @param sheetName
* @param titleNum
* @param is
@ -455,6 +457,11 @@ public class ExcelUtil<T>
public void exportExcel(HttpServletResponse response, List<T> list, String sheetName, String title)
{
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");
this.init(list, sheetName, title, Type.EXPORT);
exportExcel(response);
@ -488,7 +495,7 @@ public class ExcelUtil<T>
/**
* listexcel
*
*
* @return
*/
public void exportExcel(HttpServletResponse response)
@ -550,7 +557,7 @@ public class ExcelUtil<T>
/**
* excel
*
*
* @param index
* @param row
*/
@ -614,7 +621,7 @@ public class ExcelUtil<T>
/**
*
*
*
* @param wb
* @return
*/
@ -667,7 +674,7 @@ public class ExcelUtil<T>
/**
* Excel
*
*
* @param wb
* @return
*/
@ -681,6 +688,7 @@ public class ExcelUtil<T>
if (!headerStyles.containsKey(key))
{
CellStyle style = wb.createCellStyle();
style = wb.createCellStyle();
style.cloneStyleFrom(styles.get("data"));
style.setAlignment(HorizontalAlignment.CENTER);
style.setVerticalAlignment(VerticalAlignment.CENTER);
@ -700,7 +708,7 @@ public class ExcelUtil<T>
/**
* Excel
*
*
* @param wb
* @return
*/
@ -714,6 +722,7 @@ public class ExcelUtil<T>
if (!styles.containsKey(key))
{
CellStyle style = wb.createCellStyle();
style = wb.createCellStyle();
style.setAlignment(excel.align());
style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setBorderRight(BorderStyle.THIN);
@ -762,7 +771,7 @@ public class ExcelUtil<T>
/**
*
*
*
* @param value
* @param attr
* @param cell
@ -909,7 +918,7 @@ public class ExcelUtil<T>
/**
* POI XSSFSheet
*
*
* @param sheet
* @param textlist
* @param promptContent
@ -983,7 +992,7 @@ public class ExcelUtil<T>
/**
* =0,=1,=2
*
*
* @param propertyValue
* @param converterExp
* @param separator
@ -1224,7 +1233,7 @@ public class ExcelUtil<T>
/**
*
*
*
* @param sheetNo sheet
* @param index
*/
@ -1241,7 +1250,7 @@ public class ExcelUtil<T>
/**
*
*
*
* @param row
* @param column
* @return
@ -1301,7 +1310,7 @@ public class ExcelUtil<T>
/**
*
*
*
* @param row
* @return
*/
@ -1324,7 +1333,7 @@ public class ExcelUtil<T>
/**
*
*
*
* @param dateFormat
* @param val
* @return
@ -1390,7 +1399,7 @@ public class ExcelUtil<T>
/**
*
*
*
* @param name
* @param pojoClass
* @return

@ -27,7 +27,7 @@ import com.ruoyi.common.core.web.page.TableDataInfo;
/**
* ${functionName}Controller
*
*
* @author ${author}
* @date ${datetime}
*/
@ -63,12 +63,12 @@ public class ${ClassName}Controller extends BaseController
*/
@RequiresPermissions("${permissionPrefix}:export")
@Log(title = "${functionName}", businessType = BusinessType.EXPORT)
@PostMapping("/export")
@PostMapping(value = "/export", produces = "application/octet-stream")
public void export(HttpServletResponse response, ${ClassName} ${className})
{
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class);
util.exportExcel(response, list, "${functionName}数据");
util.exportExcel(response, list, "${functionName}数据", "${functionName}数据");
}
/**

Loading…
Cancel
Save