엑셀다운로드 ( 내부데이터연동API, 외부데이터연동API, API KEY 신청내역)
parent
8e8d4556d2
commit
e0ef2e9069
|
|
@ -8,6 +8,8 @@ import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
@ -15,10 +17,13 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import com.dbnt.faisp.util.ParamMap;
|
||||||
|
|
||||||
import egovframework.rte.psl.dataaccess.util.EgovMap;
|
import egovframework.rte.psl.dataaccess.util.EgovMap;
|
||||||
import geoinfo.admins.apiManagement.service.ApiInDataManagementService;
|
import geoinfo.admins.apiManagement.service.ApiInDataManagementService;
|
||||||
import geoinfo.comm.util.strUtil;
|
import geoinfo.comm.util.strUtil;
|
||||||
import geoinfo.session.UserInfo;
|
import geoinfo.session.UserInfo;
|
||||||
|
import geoinfo.util.ExcelMergeHeaderUtil;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -190,4 +195,33 @@ public class ApiInDataManagementController {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API 관리 > 관리 API 호출 로그 목록 엑셀다운로드
|
||||||
|
* @param workbook
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/admins/mgmtApiLog/excel.do")
|
||||||
|
public void downloadDrillingInquiryListExcel(HttpServletRequest request, HttpServletResponse response, HSSFWorkbook workbook, @RequestParam HashMap<String, Object> params) throws Exception {
|
||||||
|
|
||||||
|
HashMap<String, Object> map = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
String[] headers = {"rn","apiKey","accessId","accessType","accessTable","accessDt" ,"ipAddress"};
|
||||||
|
String[] headerName = {"No.", "API_KEY", "ACCESS_ID", "ACCESS_TYPE", "ACCESS_TABLE", "ACCESS_DT", "IP_ADDRESS"};
|
||||||
|
|
||||||
|
final int[] headerWidths = {1325, 15900, 4240, 6360, 5830, 8830, 6890};
|
||||||
|
String[] columnType = {"String", "String", "String", "String", "String", "String", "String"};
|
||||||
|
String sheetName = "Sheet1";
|
||||||
|
|
||||||
|
String excelFileName = "(API 연동 통계-내부data)호출로그";
|
||||||
|
|
||||||
|
Long totalCount = 0L;
|
||||||
|
// DB 조회
|
||||||
|
List<EgovMap> listData = (List<EgovMap>) apiInDataManagementService.selectWebApiLogList(params);
|
||||||
|
|
||||||
|
int idx = 0;
|
||||||
|
ExcelMergeHeaderUtil.listToExcel(listData, response, headers, headerName, columnType, sheetName, excelFileName);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
@ -18,6 +19,7 @@ import egovframework.rte.psl.dataaccess.util.EgovMap;
|
||||||
import geoinfo.admins.apiManagement.service.ApiKeyManagementService;
|
import geoinfo.admins.apiManagement.service.ApiKeyManagementService;
|
||||||
import geoinfo.comm.util.strUtil;
|
import geoinfo.comm.util.strUtil;
|
||||||
import geoinfo.session.UserInfo;
|
import geoinfo.session.UserInfo;
|
||||||
|
import geoinfo.util.ExcelMergeHeaderUtil;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -70,6 +72,40 @@ public class ApiKeyManagementController {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API 관리 > 관리 API 호출 로그 목록 엑셀다운로드
|
||||||
|
* @param workbook
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/admins/mgmtApiKey/excel.do")
|
||||||
|
public void downloadDrillingInquiryListExcel(HttpServletRequest request, HttpServletResponse response, HSSFWorkbook workbook, @RequestParam HashMap<String, Object> params) throws Exception {
|
||||||
|
|
||||||
|
HashMap<String, Object> map = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
String[] headers = {"rn","userid","userType","apiKey","startDt","endDt","approveYn"};
|
||||||
|
String[] headerName = {"No.", "사용자 ID", "사용자 구분", "API KEY", "신청일", "만료일", "승인상태"};
|
||||||
|
|
||||||
|
final int[] headerWidths = {1325, 15900, 4240, 6360, 5830, 8830, 6890};
|
||||||
|
String[] columnType = {"String", "String", "String", "String", "String", "String", "String"};
|
||||||
|
String sheetName = "Sheet1";
|
||||||
|
|
||||||
|
String excelFileName = "API신청내역";
|
||||||
|
|
||||||
|
// DB 조회
|
||||||
|
List<EgovMap> listData = (List<EgovMap>) apiKeyManagementService.selectWebApiKeyList(params);
|
||||||
|
|
||||||
|
int idx = 0;
|
||||||
|
for (EgovMap rowData : listData) {
|
||||||
|
// 공사기간 형식 처리: startDate ~ endDate
|
||||||
|
String approveYn = (String) rowData.get("approveYn");
|
||||||
|
rowData.put("approveYn", "Y".equals(approveYn) ? "승인" : "미승인");
|
||||||
|
|
||||||
|
}
|
||||||
|
ExcelMergeHeaderUtil.listToExcel(listData, response, headers, headerName, columnType, sheetName, excelFileName);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API 관리 > API신청 승인상태 변경
|
* API 관리 > API신청 승인상태 변경
|
||||||
* @param params
|
* @param params
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
@ -19,6 +20,7 @@ import egovframework.rte.psl.dataaccess.util.EgovMap;
|
||||||
import geoinfo.admins.apiManagement.service.ApiOutDataManagementService;
|
import geoinfo.admins.apiManagement.service.ApiOutDataManagementService;
|
||||||
import geoinfo.comm.util.strUtil;
|
import geoinfo.comm.util.strUtil;
|
||||||
import geoinfo.session.UserInfo;
|
import geoinfo.session.UserInfo;
|
||||||
|
import geoinfo.util.ExcelMergeHeaderUtil;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -189,4 +191,34 @@ public class ApiOutDataManagementController {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API 관리 > 관리 API 호출 로그 목록 엑셀다운로드
|
||||||
|
* @param workbook
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/admins/mgmtApiLog/o_excel.do")
|
||||||
|
public void downloadDrillingInquiryListExcel(HttpServletRequest request, HttpServletResponse response, HSSFWorkbook workbook, @RequestParam HashMap<String, Object> params) throws Exception {
|
||||||
|
|
||||||
|
HashMap<String, Object> map = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
String[] headers = {"rn","apiKey","accessId","accessType","accessTable","accessDt" ,"ipAddress"};
|
||||||
|
String[] headerName = {"No.", "API_KEY", "ACCESS_ID", "ACCESS_TYPE", "ACCESS_TABLE", "ACCESS_DT", "IP_ADDRESS"};
|
||||||
|
|
||||||
|
final int[] headerWidths = {1325, 15900, 4240, 6360, 5830, 8830, 6890};
|
||||||
|
String[] columnType = {"String", "String", "String", "String", "String", "String", "String"};
|
||||||
|
String sheetName = "Sheet1";
|
||||||
|
|
||||||
|
String excelFileName = "(외부 데이터 연동 통계)호출로그";
|
||||||
|
|
||||||
|
Long totalCount = 0L;
|
||||||
|
// DB 조회
|
||||||
|
|
||||||
|
List<EgovMap> listData = (List<EgovMap>) apiOutDataManagementService.selectWebApiLogList(params);
|
||||||
|
|
||||||
|
int idx = 0;
|
||||||
|
ExcelMergeHeaderUtil.listToExcel(listData, response, headers, headerName, columnType, sheetName, excelFileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
package geoinfo.admins.apiManagement.service;
|
package geoinfo.admins.apiManagement.service;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import org.apache.poi.ss.usermodel.BorderStyle;
|
||||||
import org.apache.poi.ss.usermodel.Cell;
|
import org.apache.poi.ss.usermodel.Cell;
|
||||||
import org.apache.poi.ss.usermodel.CellStyle;
|
import org.apache.poi.ss.usermodel.CellStyle;
|
||||||
import org.apache.poi.ss.usermodel.FillPatternType;
|
import org.apache.poi.ss.usermodel.FillPatternType;
|
||||||
|
import org.apache.poi.ss.usermodel.Font;
|
||||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||||
import org.apache.poi.ss.usermodel.Row;
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
|
|
@ -26,7 +27,6 @@ import org.apache.poi.ss.usermodel.VerticalAlignment;
|
||||||
import org.apache.poi.ss.util.CellRangeAddress;
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
import org.apache.poi.xssf.usermodel.XSSFDataFormat;
|
import org.apache.poi.xssf.usermodel.XSSFDataFormat;
|
||||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
import org.apache.poi.ss.usermodel.Font;
|
|
||||||
|
|
||||||
import egovframework.rte.psl.dataaccess.util.EgovMap;
|
import egovframework.rte.psl.dataaccess.util.EgovMap;
|
||||||
|
|
||||||
|
|
@ -112,7 +112,7 @@ public class ExcelMergeHeaderUtil {
|
||||||
return ExcelMergeHeaderUtil.getTimeStampString("yyyyMMdd_HHmmss_SSS");
|
return ExcelMergeHeaderUtil.getTimeStampString("yyyyMMdd_HHmmss_SSS");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void listToExcel(List<ParamMap> list, HttpServletResponse response, String[] headers, String[] headerNames, String[] columnType, String sheetName, String excelFileName) throws IOException {
|
public static void listToExcel(List<EgovMap> list, HttpServletResponse response, String[] headers, String[] headerNames, String[] columnType, String sheetName, String excelFileName) throws IOException {
|
||||||
if(ExcelMergeHeaderUtil.isNotEmpty(list)) {
|
if(ExcelMergeHeaderUtil.isNotEmpty(list)) {
|
||||||
// 메모리에 100개의 행을 유지합니다. 행의 수가 넘으면 디스크에 적습니다.
|
// 메모리에 100개의 행을 유지합니다. 행의 수가 넘으면 디스크에 적습니다.
|
||||||
XSSFWorkbook wb = new XSSFWorkbook();
|
XSSFWorkbook wb = new XSSFWorkbook();
|
||||||
|
|
@ -120,34 +120,65 @@ public class ExcelMergeHeaderUtil {
|
||||||
Row headerRow = sheet.createRow(0);
|
Row headerRow = sheet.createRow(0);
|
||||||
CellStyle cellStyle1 = wb.createCellStyle(); //쉼표들어간 숫자 양식
|
CellStyle cellStyle1 = wb.createCellStyle(); //쉼표들어간 숫자 양식
|
||||||
CellStyle cellStyle2 = wb.createCellStyle(); //숫자양식
|
CellStyle cellStyle2 = wb.createCellStyle(); //숫자양식
|
||||||
CellStyle headerStyle = wb.createCellStyle(); //숫자양식
|
CellStyle headerStyle = wb.createCellStyle(); //헤더 스타일
|
||||||
|
CellStyle borderStyle = wb.createCellStyle(); // 기본 검정 테두리 스타일
|
||||||
|
|
||||||
|
// 기본 검정 테두리 스타일 설정
|
||||||
|
borderStyle.setBorderTop(BorderStyle.THIN);
|
||||||
|
borderStyle.setBorderBottom(BorderStyle.THIN);
|
||||||
|
borderStyle.setBorderLeft(BorderStyle.THIN);
|
||||||
|
borderStyle.setBorderRight(BorderStyle.THIN);
|
||||||
|
|
||||||
|
// 글꼴 색상 흰색으로 설정
|
||||||
|
Font headerFont = wb.createFont();
|
||||||
|
headerFont.setColor(IndexedColors.WHITE.getIndex()); // 글씨 색상 흰색
|
||||||
|
headerStyle.setFont(headerFont); // 헤더 스타일에 적용
|
||||||
|
|
||||||
XSSFDataFormat format = wb.createDataFormat();
|
XSSFDataFormat format = wb.createDataFormat();
|
||||||
cellStyle1.setDataFormat(format.getFormat("#,##0"));
|
cellStyle1.setDataFormat(format.getFormat("#,##0"));
|
||||||
cellStyle2.setDataFormat(format.getFormat("#"));
|
cellStyle2.setDataFormat(format.getFormat("#"));
|
||||||
|
headerStyle.setBorderTop(BorderStyle.THIN);
|
||||||
|
headerStyle.setBorderBottom(BorderStyle.THIN);
|
||||||
|
headerStyle.setBorderLeft(BorderStyle.THIN);
|
||||||
|
headerStyle.setBorderRight(BorderStyle.THIN);
|
||||||
headerStyle.setAlignment(HorizontalAlignment.CENTER);
|
headerStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||||
|
headerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||||
headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||||
headerStyle.setFillForegroundColor((short)3);
|
headerStyle.setFillForegroundColor((short)3);
|
||||||
headerStyle.setFillForegroundColor(IndexedColors.LIME.getIndex());
|
headerStyle.setFillForegroundColor(IndexedColors.GREY_40_PERCENT.getIndex());
|
||||||
|
|
||||||
for(int i=0; i<list.size(); i++) {
|
for(int i=0; i<list.size(); i++) {
|
||||||
ParamMap rowData = list.get(i);
|
EgovMap rowData = list.get(i);
|
||||||
Row row = sheet.createRow(i+1);
|
Row row = sheet.createRow(i+1);
|
||||||
|
|
||||||
for(int j=0; j<headers.length; j++) {
|
for(int j=0; j<headers.length; j++) {
|
||||||
Cell cell = row.createCell(j);
|
Cell cell = row.createCell(j);
|
||||||
|
|
||||||
if(columnType[j].equalsIgnoreCase("Money")) {
|
Object value = rowData.get(headers[j]);
|
||||||
cell.setCellValue(rowData.getInt(headers[j]));
|
// Money 타입
|
||||||
cell.setCellStyle(cellStyle1);
|
if ("Money".equalsIgnoreCase(columnType[j])) {
|
||||||
} else if(columnType[j].equalsIgnoreCase("Int")) {
|
if (value instanceof Number) {
|
||||||
cell.setCellValue(rowData.getInt(headers[j]));
|
cell.setCellValue(((Number) value).doubleValue());
|
||||||
cell.setCellStyle(cellStyle2);
|
|
||||||
} else if(columnType[j].equalsIgnoreCase("String")) {
|
|
||||||
cell.setCellValue(rowData.getString(headers[j]));
|
|
||||||
} else {
|
} else {
|
||||||
cell.setCellValue(rowData.getString(headers[j]));
|
cell.setCellValue(0);
|
||||||
}
|
}
|
||||||
|
cell.setCellStyle(cellStyle1);
|
||||||
|
|
||||||
|
// Int 타입
|
||||||
|
} else if ("Int".equalsIgnoreCase(columnType[j])) {
|
||||||
|
if (value instanceof Number) {
|
||||||
|
cell.setCellValue(((Number) value).doubleValue());
|
||||||
|
} else {
|
||||||
|
cell.setCellValue(0);
|
||||||
|
}
|
||||||
|
cell.setCellStyle(cellStyle2);
|
||||||
|
|
||||||
|
// String 타입
|
||||||
|
} else {
|
||||||
|
cell.setCellValue(value == null ? "" : String.valueOf(value));
|
||||||
|
}
|
||||||
|
// 검정 테두리 적용
|
||||||
|
cell.setCellStyle(borderStyle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -300,172 +331,6 @@ public class ExcelMergeHeaderUtil {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void downExcel(List<ParamMap> list, HttpServletResponse response, String[] headers, String[] headerNames,String[] headerNames2, String[] columnType, String sheetName, String excelFileName) throws IOException {
|
|
||||||
if(ExcelMergeHeaderUtil.isNotEmpty(list)) {
|
|
||||||
// 메모리에 100개의 행을 유지합니다. 행의 수가 넘으면 디스크에 적습니다.
|
|
||||||
XSSFWorkbook wb = new XSSFWorkbook();
|
|
||||||
Sheet sheet = wb.createSheet(sheetName);
|
|
||||||
Row headerRow = sheet.createRow(0);
|
|
||||||
Row headerRow2 = sheet.createRow(1);
|
|
||||||
CellStyle cellStyle1 = wb.createCellStyle(); //쉼표들어간 숫자 양식
|
|
||||||
CellStyle cellStyle2 = wb.createCellStyle(); //숫자양식
|
|
||||||
CellStyle headerStyle = wb.createCellStyle(); //숫자양식
|
|
||||||
CellStyle headerStyle2 = wb.createCellStyle();
|
|
||||||
|
|
||||||
XSSFDataFormat format = wb.createDataFormat();
|
|
||||||
cellStyle1.setDataFormat(format.getFormat("#,##0"));
|
|
||||||
cellStyle2.setDataFormat(format.getFormat("#,##0"));
|
|
||||||
cellStyle2.setAlignment(HorizontalAlignment.CENTER);
|
|
||||||
headerStyle2.setAlignment(HorizontalAlignment.CENTER);
|
|
||||||
headerStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
||||||
headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
|
||||||
headerStyle.setFillForegroundColor((short)3);
|
|
||||||
headerStyle.setFillForegroundColor(IndexedColors.LIME.getIndex());
|
|
||||||
|
|
||||||
//로우그리기
|
|
||||||
for(int i=0; i<list.size(); i++) {
|
|
||||||
ParamMap rowData = list.get(i);
|
|
||||||
Row row = sheet.createRow(i+2);
|
|
||||||
|
|
||||||
for(int j=0; j<headers.length; j++) {
|
|
||||||
Cell cell = row.createCell(j);
|
|
||||||
|
|
||||||
|
|
||||||
if(columnType[j].equalsIgnoreCase("Int")) {
|
|
||||||
cell.setCellValue(rowData.getInt(headers[j]));
|
|
||||||
cell.setCellStyle(cellStyle2);
|
|
||||||
} else if(columnType[j].equalsIgnoreCase("String")) {
|
|
||||||
cell.setCellValue(rowData.getString(headers[j]));
|
|
||||||
} else {
|
|
||||||
cell.setCellValue(rowData.getString(headers[j]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//헤더
|
|
||||||
for(int j=0; j<headerNames.length; j++) {
|
|
||||||
Cell cell = headerRow.createCell(j);
|
|
||||||
cell.setCellValue(headerNames[j]);
|
|
||||||
cell.setCellStyle(headerStyle);
|
|
||||||
sheet.autoSizeColumn(j);
|
|
||||||
sheet.setColumnWidth(j, (sheet.getColumnWidth(j)) + 1000);
|
|
||||||
}
|
|
||||||
sheet.addMergedRegion(new CellRangeAddress(0,0,0,1));
|
|
||||||
for(int j=0; j<headerNames2.length; j++) {
|
|
||||||
Cell cell = headerRow2.createCell(j);
|
|
||||||
cell.setCellValue(headerNames2[j]);
|
|
||||||
cell.setCellStyle(headerStyle2);
|
|
||||||
sheet.autoSizeColumn(j);
|
|
||||||
sheet.setColumnWidth(j, (sheet.getColumnWidth(j)) + 1000);
|
|
||||||
}
|
|
||||||
//엑셀이름 한글깨짐방지
|
|
||||||
String outputFileName = new String(excelFileName.getBytes("KSC5601"), "8859_1");
|
|
||||||
|
|
||||||
response.setHeader("Set-Cookie", "fileDownload=true; path=/");
|
|
||||||
response.setHeader("Content-Disposition", String.format("attachment; filename=\""+outputFileName+"_"+ExcelMergeHeaderUtil.getTimeStampString("yyyyMMdd_HHmm")+".xlsx\""));
|
|
||||||
|
|
||||||
wb.write(response.getOutputStream());
|
|
||||||
wb.close();
|
|
||||||
} else {
|
|
||||||
createNoDataAlert(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void downEquipStatusExcel(List<ParamMap> list, HttpServletResponse response, String[] headers, String[] headerNames,String[] headerNames2, String[] columnType, String sheetName, String excelFileName) throws IOException {
|
|
||||||
if(ExcelMergeHeaderUtil.isNotEmpty(list)) {
|
|
||||||
// 메모리에 100개의 행을 유지합니다. 행의 수가 넘으면 디스크에 적습니다.
|
|
||||||
XSSFWorkbook wb = new XSSFWorkbook();
|
|
||||||
Sheet sheet = wb.createSheet(sheetName);
|
|
||||||
Row headerRow = sheet.createRow(0);
|
|
||||||
Row headerRow2 = sheet.createRow(1);
|
|
||||||
CellStyle cellStyle1 = wb.createCellStyle(); //쉼표들어간 숫자 양식
|
|
||||||
CellStyle cellStyle2 = wb.createCellStyle(); //숫자양식
|
|
||||||
CellStyle headerStyle = wb.createCellStyle(); //숫자양식
|
|
||||||
CellStyle headerStyle2 = wb.createCellStyle();
|
|
||||||
CellStyle headerStyle3 = wb.createCellStyle();
|
|
||||||
|
|
||||||
XSSFDataFormat format = wb.createDataFormat();
|
|
||||||
cellStyle1.setDataFormat(format.getFormat("#,##0"));
|
|
||||||
cellStyle2.setDataFormat(format.getFormat("#,##0"));
|
|
||||||
cellStyle2.setAlignment(HorizontalAlignment.CENTER);
|
|
||||||
headerStyle2.setBorderTop(BorderStyle.THIN);
|
|
||||||
headerStyle2.setBorderBottom(BorderStyle.THIN);
|
|
||||||
headerStyle2.setBorderLeft(BorderStyle.THIN);
|
|
||||||
headerStyle2.setBorderRight(BorderStyle.THIN);
|
|
||||||
headerStyle2.setAlignment(HorizontalAlignment.CENTER);
|
|
||||||
headerStyle2.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
|
||||||
headerStyle2.setFillForegroundColor((short)3);
|
|
||||||
headerStyle2.setFillForegroundColor(IndexedColors.LIME.getIndex());
|
|
||||||
headerStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
||||||
headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
|
||||||
headerStyle.setFillForegroundColor((short)3);
|
|
||||||
headerStyle.setFillForegroundColor(IndexedColors.LIME.getIndex());
|
|
||||||
headerStyle3.setBorderTop(BorderStyle.THIN);
|
|
||||||
headerStyle3.setBorderBottom(BorderStyle.THIN);
|
|
||||||
headerStyle3.setBorderLeft(BorderStyle.THIN);
|
|
||||||
headerStyle3.setBorderRight(BorderStyle.THIN);
|
|
||||||
headerStyle3.setAlignment(HorizontalAlignment.CENTER);
|
|
||||||
headerStyle3.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
|
||||||
headerStyle3.setFillForegroundColor((short)3);
|
|
||||||
headerStyle3.setFillForegroundColor(IndexedColors.LIME.getIndex());
|
|
||||||
|
|
||||||
|
|
||||||
//로우그리기
|
|
||||||
for(int i=0; i<list.size(); i++) {
|
|
||||||
ParamMap rowData = list.get(i);
|
|
||||||
Row row = sheet.createRow(i+2);
|
|
||||||
|
|
||||||
for(int j=0; j<headers.length; j++) {
|
|
||||||
Cell cell = row.createCell(j);
|
|
||||||
|
|
||||||
|
|
||||||
if(columnType[j].equalsIgnoreCase("Int")) {
|
|
||||||
cell.setCellValue(rowData.getInt(headers[j]));
|
|
||||||
cell.setCellStyle(cellStyle2);
|
|
||||||
} else if(columnType[j].equalsIgnoreCase("String")) {
|
|
||||||
cell.setCellValue(rowData.getString(headers[j]));
|
|
||||||
} else {
|
|
||||||
cell.setCellValue(rowData.getString(headers[j]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//헤더
|
|
||||||
for(int j=0; j<headerNames.length; j++) {
|
|
||||||
Cell cell = headerRow.createCell(j);
|
|
||||||
cell.setCellValue(headerNames[j]);
|
|
||||||
cell.setCellStyle(headerStyle3);
|
|
||||||
sheet.autoSizeColumn(j);
|
|
||||||
sheet.setColumnWidth(j, (sheet.getColumnWidth(j)) + 1000);
|
|
||||||
}
|
|
||||||
sheet.addMergedRegion(new CellRangeAddress(0,0,0,4));
|
|
||||||
sheet.addMergedRegion(new CellRangeAddress(0,0,5,10));
|
|
||||||
sheet.addMergedRegion(new CellRangeAddress(0,0,11,16));
|
|
||||||
sheet.addMergedRegion(new CellRangeAddress(0,0,17,22));
|
|
||||||
sheet.addMergedRegion(new CellRangeAddress(0,0,23,28));
|
|
||||||
sheet.addMergedRegion(new CellRangeAddress(0,0,29,31));
|
|
||||||
for(int j=0; j<headerNames2.length; j++) {
|
|
||||||
Cell cell = headerRow2.createCell(j);
|
|
||||||
cell.setCellValue(headerNames2[j]);
|
|
||||||
cell.setCellStyle(headerStyle2);
|
|
||||||
sheet.autoSizeColumn(j);
|
|
||||||
sheet.setColumnWidth(j, (sheet.getColumnWidth(j)) + 1000);
|
|
||||||
}
|
|
||||||
//엑셀이름 한글깨짐방지
|
|
||||||
String outputFileName = new String(excelFileName.getBytes("KSC5601"), "8859_1");
|
|
||||||
|
|
||||||
response.setHeader("Set-Cookie", "fileDownload=true; path=/");
|
|
||||||
response.setHeader("Content-Disposition", String.format("attachment; filename=\""+outputFileName+"_"+ExcelMergeHeaderUtil.getTimeStampString("yyyyMMdd_HHmm")+".xlsx\""));
|
|
||||||
|
|
||||||
wb.write(response.getOutputStream());
|
|
||||||
wb.close();
|
|
||||||
} else {
|
|
||||||
createNoDataAlert(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void createNoDataAlert(HttpServletResponse response) throws IOException {
|
private static void createNoDataAlert(HttpServletResponse response) throws IOException {
|
||||||
response.setHeader("Content-Type", "text/html; charset=UTF-8");
|
response.setHeader("Content-Type", "text/html; charset=UTF-8");
|
||||||
PrintWriter out = response.getWriter();
|
PrintWriter out = response.getWriter();
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@
|
||||||
background: #fff; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); padding: 20px;
|
background: #fff; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); padding: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-header {
|
.card-header, .container-header {
|
||||||
display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px;
|
display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -308,6 +308,7 @@
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<input type="hidden" id="excelDownload" name="excelDownload" value="" >
|
||||||
|
|
||||||
<!-- 일일 접속량 -->
|
<!-- 일일 접속량 -->
|
||||||
<div class="chart-container">
|
<div class="chart-container">
|
||||||
|
|
@ -460,7 +461,10 @@
|
||||||
|
|
||||||
<!-- 로그 테이블 -->
|
<!-- 로그 테이블 -->
|
||||||
<div class="table-container">
|
<div class="table-container">
|
||||||
|
<div class="container-header">
|
||||||
<h3>API 호출 로그</h3>
|
<h3>API 호출 로그</h3>
|
||||||
|
<button class="export-btn" onClick="javascript:clickExcelDownload()">엑셀 다운로드</button>
|
||||||
|
</div>
|
||||||
<table>
|
<table>
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col style="width: 3%">
|
<col style="width: 3%">
|
||||||
|
|
@ -1006,6 +1010,16 @@
|
||||||
document.body.removeChild(a);
|
document.body.removeChild(a);
|
||||||
URL.revokeObjectURL(url);
|
URL.revokeObjectURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 엑셀 다운로드
|
||||||
|
function clickExcelDownload(){
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
|
||||||
|
// AJAX가 아닌 직접 다운로드 요청
|
||||||
|
window.location.href = "/admins/mgmtApiLog/excel.do?" + params.toString();
|
||||||
|
$('#excelDownload').val("");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API 호출 통계 날짜 유효검사
|
* API 호출 통계 날짜 유효검사
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,26 @@
|
||||||
background-color: #1A73E8;
|
background-color: #1A73E8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.export-btn {
|
||||||
|
float: right;
|
||||||
|
background-color: #007bff;
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
padding: 8px 14px;
|
||||||
|
border-radius: 5px;
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 14px;
|
||||||
|
transition: background-color 0.2s;
|
||||||
|
}
|
||||||
|
.export-btn:hover {
|
||||||
|
background-color: #0056b3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container-header {
|
||||||
|
display: flex; justify-content: flex-end; align-items: center; margin: 15px 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* API 신청 내역 테이블 */
|
/* API 신청 내역 테이블 */
|
||||||
.table-container {
|
.table-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
@ -152,7 +172,11 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="table-container home-trainning">
|
|
||||||
|
<div class="container-header">
|
||||||
|
<button class="export-btn" onClick="javascript:clickExcelDownload()">엑셀 다운로드</button>
|
||||||
|
</div>
|
||||||
|
<div class="table-container home-trainning" style="margin-top: 0">
|
||||||
<table class="Table_Main course-list-table">
|
<table class="Table_Main course-list-table">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col style="width: 3%">
|
<col style="width: 3%">
|
||||||
|
|
@ -241,6 +265,15 @@
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 엑셀 다운로드
|
||||||
|
function clickExcelDownload(){
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
|
||||||
|
// AJAX가 아닌 직접 다운로드 요청
|
||||||
|
window.location.href = "/admins/mgmtApiKey/excel.do?" + params.toString();
|
||||||
|
$('#excelDownload').val("");
|
||||||
|
}
|
||||||
|
|
||||||
// 승인처리하기
|
// 승인처리하기
|
||||||
function toggleApproveKey(ele) {
|
function toggleApproveKey(ele) {
|
||||||
let apiSeq = $(ele).data("seq")
|
let apiSeq = $(ele).data("seq")
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@
|
||||||
background: #fff; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); padding: 20px;
|
background: #fff; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); padding: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-header {
|
.card-header, .container-header {
|
||||||
display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px;
|
display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -308,7 +308,7 @@
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<input type="hidden" id="excelDownload" name="excelDownload" value="" >
|
||||||
<!-- 일일 접속량 -->
|
<!-- 일일 접속량 -->
|
||||||
<div class="chart-container">
|
<div class="chart-container">
|
||||||
<h3>📈 일일 접속량</h3>
|
<h3>📈 일일 접속량</h3>
|
||||||
|
|
@ -460,7 +460,10 @@
|
||||||
|
|
||||||
<!-- 로그 테이블 -->
|
<!-- 로그 테이블 -->
|
||||||
<div class="table-container">
|
<div class="table-container">
|
||||||
|
<div class="container-header">
|
||||||
<h3>API 호출 로그</h3>
|
<h3>API 호출 로그</h3>
|
||||||
|
<button class="export-btn" onClick="javascript:clickExcelDownload()">엑셀 다운로드</button>
|
||||||
|
</div>
|
||||||
<table>
|
<table>
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col style="width: 3%">
|
<col style="width: 3%">
|
||||||
|
|
@ -1007,6 +1010,16 @@
|
||||||
document.body.removeChild(a);
|
document.body.removeChild(a);
|
||||||
URL.revokeObjectURL(url);
|
URL.revokeObjectURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 엑셀 다운로드
|
||||||
|
function clickExcelDownload(){
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
|
||||||
|
// AJAX가 아닌 직접 다운로드 요청
|
||||||
|
window.location.href = "/admins/mgmtApiLog/o_excel.do?" + params.toString();
|
||||||
|
$('#excelDownload').val("");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API 호출 통계 날짜 유효검사
|
* API 호출 통계 날짜 유효검사
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue