-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResponseUtil.java
More file actions
36 lines (25 loc) · 940 Bytes
/
ResponseUtil.java
File metadata and controls
36 lines (25 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package utils;
import java.io.OutputStream;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.PageContext;
import org.apache.jasper.tagplugins.jstl.core.Out;
import org.apache.poi.ss.usermodel.Workbook;
public class ResponseUtil {
// public static void write(HttpServletResponse response,Object o)throws Exception{
// response.setContentType("text/html;charset=utf-8");
// PrintWriter out=response.getWriter();
// out.print(o.toString());
// out.flush();
// out.close();
// }
//
public static void export(HttpServletResponse response,Workbook wb,String fileName)throws Exception{
response.setHeader("Content-Disposition", "attachment;filename="+new String(fileName.getBytes("utf-8"),"iso8859-1"));
response.setContentType("application/ynd.ms-excel;charset=UTF-8");
OutputStream os=response.getOutputStream();
wb.write(os);
os.flush();
os.close();
}
}