|
@ -27,10 +27,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
import java.io.OutputStream;
|
|
|
import java.math.BigInteger;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
@ -104,14 +106,25 @@ public class FacilityService extends BaseJpaService<Facility, FacilityDao> {
|
|
|
* @param facilityList 用户列表
|
|
|
* @throws ManageException
|
|
|
*/
|
|
|
public void exportFacilityExcel(HttpServletResponse response, List<Facility> facilityList) throws ManageException {
|
|
|
public void exportFacilityExcel(HttpServletRequest request, HttpServletResponse response, List<Facility> facilityList) throws ManageException {
|
|
|
try {
|
|
|
String fileName = "健康小屋-设施列表";
|
|
|
String fileName = "健康小屋-设施列表.xlsx";
|
|
|
// 对文件进行url编码
|
|
|
if (request.getHeader("user-agent").toLowerCase().contains("msie")//ie10以
|
|
|
|| request.getHeader("user-agent").toLowerCase().contains("like gecko")// ie10及以上取消了msie用户代理字符串
|
|
|
) {
|
|
|
// IE
|
|
|
fileName = URLEncoder.encode(fileName, "UTF-8");
|
|
|
} else {
|
|
|
// 非IE
|
|
|
fileName = new String(fileName.getBytes("utf-8"), "ISO8859-1");
|
|
|
}
|
|
|
//设置下载
|
|
|
response.setCharacterEncoding("utf-8");
|
|
|
response.setContentType("octets/stream");
|
|
|
response.setHeader("Content-Disposition", "attachment; filename="
|
|
|
+ new String(fileName.getBytes("gb2312"), "ISO8859-1") + ".xlsx");
|
|
|
response.setCharacterEncoding("UTF-8");
|
|
|
fileName = new String(fileName.getBytes("UTF-8"), "iso-8859-1");
|
|
|
response.setContentType("application/x-msdownload");
|
|
|
response.setHeader("Content-Type", "application/octet-stream");
|
|
|
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
|
|
|
OutputStream os = response.getOutputStream();
|
|
|
//写excel
|
|
|
Workbook workbook = new XSSFWorkbook();
|