https://github.com/heowc/SpringBootSample/tree/master/SpringBootExcel
heowc/SpringBootSample
spring boot sample source . Contribute to heowc/SpringBootSample development by creating an account on GitHub.
github.com
추가적으로
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
// 한글 파일 이름
private void setFileName(HttpServletResponse response, String fileName) {
String header = getBrowser(this.request);
try {
if (header.contains("MSIE")) {
response.setHeader("Content-Disposition", "attachment;filename=" + getFileExtension(docName) + ";");
} else if (header.contains("Firefox")) {
String docName = new String(fileName.getBytes("UTF-8"), "ISO-8859-1");
response.setHeader("Content-Disposition", "attachment; filename=\"" + getFileExtension(docName) + "\"");
} else if (header.contains("Opera")) {
String docName = new String(fileName.getBytes("UTF-8"), "ISO-8859-1");
response.setHeader("Content-Disposition", "attachment; filename=\"" + getFileExtension(docName) + "\"");
} else if (header.contains("Chrome")) {
String docName = new String(fileName.getBytes("UTF-8"), "ISO-8859-1");
response.setHeader("Content-Disposition", "attachment; filename=\"" + getFileExtension(docName) + "\"");
}
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4f; text-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none; color:white">cs |
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
|
// Mybatis에서 데이터를 받으면 HashMap 안에 타입이 제 각각 들어가므로
// 그 타입에 맞춰서 setCellValue 함수에 들어갈 수 있도록 변환해야 함
private void createRow(Sheet sheet, List<Object> cellList, int rowNum) {
Row row = sheet.createRow(rowNum);
for (int i = 0; i < size; i++) {
{
row.createCell(i).setCellValue(((Integer)cellList.get(i)).doubleValue());
}
{
row.createCell(i).setCellValue((String)cellList.get(i));
}
{
Timestamp t = (Timestamp)cellList.get(i);
Cell cell = row.createCell(i);
cell.setCellStyle(this.cellDateTimeStyle);
cell.setCellValue( new Date( t.getTime() ) );
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4f; text-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none; color:white">cs |