js 내보내기 형식의 Excel 인스턴스 method_javascript 기술

WBOY
풀어 주다: 2016-05-16 17:28:45
원래의
1217명이 탐색했습니다.
코드 복사 코드는 다음과 같습니다.

function getTableDataByXML(inTable, inWindow) {
    var 행 = 0;
    //alert("getTblData is " inWindow);
    var tblDocument = document;
    if (! !inWindow && inWindow != "") {
        if (!document.all(inWindow)) {
            null 반환;
        }
        else {
            tblDocument = 평가(inWindow).문서 ;
        }
    }
    var inTbl = tblDocument.getElementById(inTable);
    var outStr = "n";
    outStr = outStr "n";
    outStr = outStr " outStr = outStr " xmlns:o="urn:schemas-microsoft-com:office:office"";
    outStr = outStr " xmlns:x="urn:schemas-microsoft-com:office:excel"";
    outStr = outStr " xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">n";
    outStr = outStr "n";
    outStr = outStr "n";
    var re = /^[0-9] .?[0-9]*$/; //是否为数字
    if (inTbl != null) {
        for (var j = 0; j < inTbl.rows.length; j ) {
            outStr = "n";
            for (var i = 0; i < inTbl.rows[j].cells.length; i ) {
               if (i == 0 && 행 > 0 ) {
                   outStr = "n";
                 행 -= 1;
                }
               var cellValue = inTbl.rows[j].cells[i].innerText;
               //小于12位数字용Number
               if(re.test(cellValue) && (new String(cellValue) ). 길이 < 11){
                    outStr = outStr "" cellValue "n";
                }else{
                  outStr = outStr "" cellValue "n";
               }
               if (inTbl.rows[j].cells[i].colSpan > 1) {
                  for (var k = 0; k < inTbl.rows[j].cells[i].colSpan - 1; k ) {
                    outStr = " n";
                   }
               }
if (i == 0) {
if (rows == 0 && inTbl.rows[j].cells[i].rowSpan > 1) {
행 = inTbl.rows[j] .cells[i].rowSpan - 1;
}
}
}
outStr = "
n";
}
}
else {
outStr = null;
Alert("내보내려는 테이블이 존재하지 않습니다!!");
return;
}
outStr = outStr "
nn
";
return outStr;
}

위 함수는 원래 txt 파일을 내보내는 함수였습니다. 엑셀 파일을 xml 파일로 저장하면, 엑셀이 인식할 수 있는 내용 형식의 xml 파일을 얻을 수 있습니다.
관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!