Answer the question
In order to leave comments, you need to log in
How to extract data from the clipboard when copying Excel cells?
The situation is this. Let's say we copy 2 selected cells in Excel (one name, another number). If you press insert in Excel, it understands that these are 2 different cells and inserts them into 2 cells.
Is it possible to implement a button on the page, in which data will be inserted into 2 inputs separately (1 input - the first cell, 2 - the second)? Where to find this data via JS?
Answer the question
In order to leave comments, you need to log in
Copy these two cells and paste into a simple text editor (like Notepad). And you will see that the text will be in the form of two lines, separated by tabs \t . Accordingly, when pasting the copied on your page, you can break the pasted by the tab character, and shove the parts of the line into the necessary inputs ...
This is elementary, Watson!
within one page (one JS script), which you will not reload, most likely you can twist it somehow
document.addEventListener('copy', (e) => {
// тут можно поймать ctrl+c
// и например записать значения инпутов в переменную / сторадж
});
document.addEventListener('paste', (e) => {
// а тут ctrl+v
});
document.addEventListener('copy', function(e){
e.clipboardData.setData('text/plain', 'ничего ты не скопируешь');
e.preventDefault();
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question