首頁 >web前端 >js教程 >js匯出格式化的excel 實例方法_javascript技巧

js匯出格式化的excel 實例方法_javascript技巧

WBOY
WBOY原創
2016-05-16 17:28:451282瀏覽
複製程式碼 程式碼如下:

function getTableDataByXML(inTable, inWindow) {
    var rows = 0;
    //alert("getTblData is " inWindow);
    var tblDocument = document;
    if (! !inWindow && inWindow != "") {
        if (!document.all(inWindow)) {
           else {
            tblDocument = eval(inWindow).document ;
        }
    }
    var inTbl = tblDocument.getElementById(inTable); ? "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 He 0">n";
            for (var i = 0; i   🎜> outStr = "n";
                                   var cellValue = inTbl.rows[j ].cells[i].innerText;
                //小於12 位數字使用Number
      🎜>                    outStr = outStr "" cellValue "n";
               " cellValue "n";
                }
       >                    for (var k = 0; inTbl.rows[j].cells[i].colSpan - k ) {
                    >n";
                    }
           
                if (i == 0) {
            ) {
                        rows = inTbl.rows[j]. cells[i].rowSpan - 1;
                    }
          }
       }
            outStr = "n";
        }
  outStr = null;
        alert("你要匯出的表不存在!!");
        return;
  Workbook>";
    return outStr;
}


上述函數原本是匯出txt檔案的函數。把excel文件另存為一個xml文件,就可以得到excel能辨識什麼內容格式的xml檔。
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn