3

I'm trying to access copied excel data via clipboard in JavaScript. I find the options to getData in the format of plain text or text/html.

If it has to be created as one associate array, is looping and parsing over the data as text/html or plain text the only option ?

Ex- the expected output object of the copied excel data shall be,

[{column1 : value1,column2:value 2},{}];

This is the code i'm using for accessing clipboard data

document.body.addEventListener("paste", function(e){
    var clipboardData, oData;
    e.stopPropagation();
    e.preventDefault();

    // Get pasted data via clipboard API
    clipboardData = e.clipboardData || window.clipboardData;
    oData = clipboardData.getData('text/html');
});
sakthi
  • 929
  • 6
  • 18
  • 1
    Did you search before asking this? https://stackoverflow.com/questions/1095131/paste-excel-data-into-html-table – epascarello Feb 05 '18 at 13:29
  • @epascarello: Did you read the highlighted part of the question ? I was actually looking out for some hack solutions if already available instead of looping over plain text / html. Thanks for the link though. – sakthi Feb 05 '18 at 13:44
  • 1
    There is no solutions other than really looping. – epascarello Feb 05 '18 at 13:48

0 Answers0