Following sample reads data from clipboard and tries to parse them and format back to table.
// prepare result
var resE = document.getElementById("result");
var res = "";
resE.innerHTML = "";
// read clipboard
var s = window.clipboardData.getData("Text");
// parse clipboard data
var lines = s.split(String.fromCharCode(13,10));
if (s.indexOf(String.fromCharCode(13,10)) == -1 || s.indexOf(String.fromCharCode(9)) == -1)
{
res = "(invalid data)";
}
else
{
var cols = lines[0].split(String.fromCharCode(9));
res = "Table size: " + lines.length + "x" + cols.length + "
";
res += "
" + (cols[j] == "" ? "~" : cols[j]); } res += " |
}
// output result
resE.innerHTML = res;