2. [서버모듈 : Spring, Spring Boot]MultipartFilter 적용 후 엑셀 다운로드/업로드 되지 않을때

3. [서버모듈] Html Filter, Xss Filter 적용 후 엑셀 다운로드/업로드가 되지 않는 경우

4. [서버모듈: spring security]csrf 토큰 설정 및 X-Frame-Options 해결방법


위의 내용을 모두 확인 하였는데도 엑셀 다운로드/업로드가 되지 않는 경우 아래의 내용을 확인하여 본다.


1. 다운로드 & 업로드 공통 사항

1) (Cfg) Export 경로 확인 하기
(Cfg) Export 에서 다운로드 처리할 페이지 경로를 설정하는데 이 경로가 맞는지 확인한다.

개발자 도구[F12] --> 네트워크탭으로 이동 --> 엑셀 다운로드 또는 엑셀 업로드 버튼 클릭 후 호출되는 url 경로가 정확한지 확인한다.

 

2) jar 파일이 WEB-INF/lib 폴더에 설정되었는지 확인하기
poi 라이브러리를 이용하여 개발 하였기 때문에 was 기동시 관련 파일들이 정상적으로 올라왔는지 확인 해야 한다.

poi, poi.ooxml, poi-ooxml-schemas 이 3개의 파일이 정상적으로 로드 되었는지 확인한다.


Down2Excel.jsp에 아래 내용 삽입 후 서버콘솔에 찍히는 내용을 확인한다.


down = new IBSheetDown();


down.setLog(true); //업로드는  load.setLog(true);

System.out.println(com.ibleaders.ibsheet.util.Version.getVersion()); // jar 및 POI 버전정보 출력.



[getVersion 로그]

********************************************************************************

# ibsheet8-1.1.12

# IBSheet(H) 8.0.0.0~

# IBChart(H) 7.3.0.1~

********************************************************************************

Class Info  : org.apache.poi.ss.usermodel.Workbook

jar path    : /C:/tomcat/tomcat-8.5_servertest/webapps/ibsheet7_sample/WEB-INF/lib/poi-4.1.2.jar

jar Version : Apache POI 4.1.2

Required Version : POI 3.8 beta3 or later

********************************************************************************

Class Info  : org.apache.poi.ooxml.POIXMLDocument

jar path    : /C:/tomcat/tomcat-8.5_servertest/webapps/ibsheet7_sample/WEB-INF/lib/poi-ooxml-4.1.2.jar

jar Version : Apache POI 4.1.2

Required Version : POI 3.8 beta3 or later

********************************************************************************

Class Info  : org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbookPr

jar path    : /C:/tomcat/tomcat-8.5_servertest/webapps/ibsheet7_sample/WEB-INF/lib/poi-ooxml-schemas-4.1.2.jar

jar Version : Apache POI 4.1.2

Required Version : POI 3.8 beta3 or later

********************************************************************************

Class Info  : org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook

jar path    : /C:/tomcat/tomcat-8.5_servertest/webapps/ibsheet7_sample/WEB-INF/lib/poi-ooxml-schemas-4.1.2.jar

jar Version : Apache POI 4.1.2

Required Version : POI 3.8 beta3 or later

********************************************************************************

Class Info  : org.apache.xmlbeans.XmlBeans

jar path    : /C:/tomcat/tomcat-8.5_servertest/webapps/ibsheet7_sample/WEB-INF/lib/xmlbeans-3.1.0.jar

jar Version :

Required Version : XMLBeans 2.3.0 or later

********************************************************************************

POI Core Library file:/C:/tomcat/tomcat-8.5_servertest/webapps/ibsheet7_sample/WEB-INF/lib/poi-4.1.2.jar

POI OOXML Library file:/C:/tomcat/tomcat-8.5_servertest/webapps/ibsheet7_sample/WEB-INF/lib/poi-ooxml-4.1.2.jar



[setLog 로그] 

Debug: ibsheet8-1.1.12

Debug: Down2Excel start...

Debug: [2023.08.18 14:34:06] Max:3,760,193,536, Total:1,488,977,920, Free:1,330,098,888, Used:158,879,032

Debug: fileName=Excel.xls, fileType=xls

Debug: excel mode=POI //이부분이 POI로 나와야 정상적으로 poi가 잘 적용된 것이다.

Debug: ##  전문분석 소요시간 : 0.004초

Debug:  강제 타입설정 fileType=xls

Debug: excel mode=POI //이 부분이 POI로 찍혀야 된다.

Debug: POI addSheet Sheet

Debug: Download Option : StartRow = 0

Debug: Download Option : Down Header = true

Debug: Download Option : Header Rows = 1

Debug: Download Option : Sum Rows = 1

Debug: Download Option : Title Rows = 3

Debug: Download Option : TopArea Rows = 0

Debug: Download Option : BottomArea Rows = 0

Debug: Sheet Finalize Index=0, SheetName=Sheet, total rows=38

Debug: [2023.08.18 14:34:06] Max:3,760,193,536, Total:1,488,977,920, Free:1,277,495,472, Used:211,482,448

Debug: ##  다운로드 총 소요시간 : 0.113초

Debug: Down2Excel End...

Debug: [2023.08.18 14:34:06] Max:3,760,193,536, Total:1,488,977,920, Free:1,277,495,472, Used:211,482,448


3) 그 외 에러 확인하기

Down2Excel.jsp 또는 LoadExcel.jsp 소스코드에서 catch (Exception e) 와 catch (Error e) 부분에 에러찍는 부분이 주석으로 되어 있다.

주석을 해제 후 서버 콘솔에 찍히는 에러 로그를 확인 후 기술지원에 연락하여 지원 받는다.


catch (Exception e) {

            response.setContentType("text/html;charset=utf-8");

            response.setCharacterEncoding("utf-8");

            response.setHeader("Content-Disposition", "");

            

            //e.printStackTrace();

            OutputStream out2 = response.getOutputStream();

            out2.write(("<script>alert('An error has occurred while downloading the file.');</script>").getBytes());

            out2.flush();

    } catch (Error e) {

            response.setContentType("text/html;charset=utf-8");

            response.setCharacterEncoding("utf-8");

            response.setHeader("Content-Disposition", "");

            

            //e.printStackTrace();

            OutputStream out2 = response.getOutputStream();

            out2.write(("<script>alert('An error has occurred while downloading the file.');</script>").getBytes());

            out2.flush();

          

    }



2. 업로드

1) Temp 폴더 확인하기

Temp 폴더에 파일을 생성 하기 때문에 Temp가 존재 하는지, OS가 Red Hat 계열일 경우 권한이 있는지 체크 한다.

LoadExcel.jsp에 아래 코드 삽입하여 Temp 폴더의 위치를 파악한다.

System.out.println(System.getProperty("java.io.tmpdir"));


2) DRM이 걸린 엑셀 파일을 Load하였는지 확인

DRM 처리가 되어 난독이 된 엑셀 파일을 읽을 수 없다.

DRM을 해제 하여 Load 하거나 LoadExcel.jsp 파일에서 DRM 해제 로직을 삽입한다.