html to excel 문의

html to excel 문의

QA

html to excel 문의

본문

깊은 지식이 없다보니 문의가 많아 집니다,

 

googling 해서 좋은 예제를 찾아서 html 을 excel 화일로 변경하는데 chrome과 explorer에서 Local(제 컴:윈도우/Appache)에서 성공했는데 web host(cafe24)에서는 저장이 안되네요.(Save As 탐색창까지 나옴)

하지만 그 예제를 이용해 orderform.php에 적용했는데 explorer에서는 에러는 없는데 Save As 탐색창도 나오지 않습니다.(Local과 Web 동일) 

 

Q1. Local에서는 되고 Web에서 안되는 이유가 뭔가요? 탐색창으로 저장할 폴더까지 정했는데 안됩니다.

Q2. 영카트에서 사용하는 js 모듈과 혹시 쫑나는것이 있나요?

 

미리 답변 감사드립니다.

 

 

iframe을 이용해 open, write, close, execCommand를 적용시킨것


<iframe id="myIframe" style="display:none"></iframe>
<a id="downloadLink" onclick="exportF(this)">Export to excel</a>
<script>
function exportF1(elem) {
  var table = document.getElementById("table");
  var html = table.outerHTML;
  var url = 'data:application/vnd.ms-excel,' + escape(html); // Set your html table into url 
  elem.setAttribute("href", url);
  elem.setAttribute("download", "export.xls"); // Choose the file name
  return false;
}
function exportF(elem) {
    var ua = window.navigator.userAgent;
    var msie = ua.indexOf("MSIE ");
    var tab_text = '<table><tr><td>hello</td><td>world</td></tr></table>';
    if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./))      // If Internet Explorer
    {
        myIframe.document.open("txt/html", "replace");
        myIframe.document.write(tab_text);
        myIframe.document.close();
        myIframe.focus();
        sa = myIframe.document.execCommand("SaveAs", true, document.title + ".xls");
        return true;
    }
    else {
        window.open('data:application/vnd.ms-excel,' + encodeURIComponent(tab_text));  ;
        return true;
    }
}
</script>

 

이 질문에 댓글 쓰기 :

답변 1

답변을 작성하시기 전에 로그인 해주세요.
전체 123,531 | RSS
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT