'How to copy to clipboard using JavaScript where the data will paste separately to each cell in google sheets

I thought by creating an HTML table format will paste to each cell but instead, it only pastes to one cell. for example

let copyTable = e => {
   e.clipboardData.setData('text/html', '<tr><td>Seperate</td><td>each</td><td>word</td></tr >')
   e.preventDefault()
}

Output

A B C
1 Seperateeachword
2

When I use the <br> instead I was able to have each word go to a separate cell

let copyTable = e => {
    e.clipboardData.setData('text/html', 'Seperate<br>each<br>word')
    e.preventDefault()
}

Output

A B C
1 Seperate
2 each
3 word

The only issue I am having now is how to paste data where it goes from A to C and so on instead of going from 1 to 3. I know I could paste special on google sheets and click transposed but I would like to eventually paste tables that can range from A1 to H10.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source