2010년 2월 2일 화요일

[참고/오류가이드]Excel.Application 을 사용하여 엑셀 파일 열기에 실패하는 경우 (Can't Open Excel File) 가이드

제    목 :        
Excel.Application 을 사용하여 엑셀 파일 열기에 실패하는 경우 (Can't Open Excel File) 가이드

개    괄 :        
Excel.Application 사용 시 “Can't Open Excel File” 메시지가 나오는 경우에 대한 문제점 분석 과 가이드 입니다.

문 제 점 :        
[문제점]
-        fakepath ::인터넷익스플로러8 업로드오류
[원  인]
-        인터넷 익스플로러 8에서 보안에 관련된 사항이 변경됨

[해결방법]
- 인터넷 익스플로어(IE) 도구메뉴 -> 인터넷 옵션 에서 보안 탭 -> 사용자 지정 수준 클릭
- 보안사항에 대한 설정 중 "파일을 서버에 업 로드 할 때 로컬 디렉토리 경로 포함"  이라는 항목을 사용 안함 으로 되있는 것을 사용으로 변경



[참조 블로그] http://blog.naver.com/tnsk8080?Redirect=Log&logNo=10069423935

문제사항 및 해결방법 :        
위는 IE 자체적으로 보안을 변경하여 해결하는 방법입니다. 이는 IE의 옵션 변경을 하여야 하므로 번거로움이 있습니다. 이에 Max Component 중에 Input File Component 가 있습니다. 이를 이용한 Sample 가이드를 참고 하시기 바랍니다.

[Sample]
-        기본적으로 Max Ansi 버전을 기준으로 설명합니다. 만일 Unicode를 사용하시는 경우 CLSID를 변경 하시면 됩니다.

1.        Input File 컴포넌트 선언

<object id=tb_InputFile classid=CLSID:C722848E-C7EE-4DC6-947E-C2CD49BBA9DE
        style="position:absolute; left:355; top=55; width=110; height=23;visibility=hidden;">
<param name="Text"                value='FileOpen'>
<param name="Enable"        value="true">
</object>

엑셀 업로드 (FileComponent Upload) :
        <input type=button value="엑셀 업로드 (FileComponent Upload)" onClick="Open_File()">


2.        자바 스크립트에서 Open 함수를 사용하여 파일 경로를 얻어옴

< function Open_File() {
                tb_InputFile.Open();

                SetDataHeader(tb_DataSet);
//alert(tb_InputFile.Value);
                //LoadExcelData 옵션처리
                var strExcelFileName = "'"+tb_InputFile.Value+"'"; //파일이름
                var nStartRow = 0; //시작Row
                var nEndRow = 0; //끝Row
                var nReadType = 0; //읽기모드
                var nBlankCount = 3; //공백row개수
                var nLFTOCR = 0; //줄바꿈처리
                var nFireEvent = 1;//이벤트발생
                var nSheetIndex = 1; //Sheet Index 추가

                var stropt = strExcelFileName; //1st
                stropt += "," + nStartRow; //2nd
                stropt += "," + nEndRow; //3rd
                stropt += "," + nReadType; //4th
                stropt += "," + nBlankCount; //5th
                stropt += "," + nLFTOCR; //6th
                stropt += "," + nFireEvent; //7th
                stropt += "," + nSheetIndex //8th

                var obj = document.getElementById("tb_DataSet");

                fn_setTime(txtStart);
                obj.Do("Excel.Application", stropt);
                fn_setTime(txtEnd);

        }
</script>

참고URL : http://www.gauce.com/zboard.php?id=componentFAQ&page=1&sn1=&divpage=1&sn=off&ss=on&sc=on&select_arrange=headnum&desc=asc&no=136