前端_把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);