前端_把excel表的数据粘贴到网页table(未测试)

 var clipText = window.clipboardData.getData('Text');  
clipRows = clipText.split(String.fromCharCode(13));
for (i=0; i<clipRows.length; i++) {
clipRows[i] = clipRows[i].split(String.fromCharCode(9));
}
newTable = document.createElement("table");
newTable.border = 1;
for (i=0; i<clipRows.length - 1; i++) {
newRow = newTable.insertRow();
for (j=0; j<clipRows[i].length; j++) {
newCell = newRow.insertCell();
if (clipRows[i][j].length == 0) {
newCell.innerText = ' ';
} else {
newCell.innerText = clipRows[i][j];
}
}
} document.body.appendChild(newTable);

 

posted @ 2014-02-18 18:05  logep  阅读(453)  评论(0编辑  收藏  举报