How can I upon custom button click copy all the cells the user has selected and be able to paste in Excel such that a cell in the HOT corresponds to a cell in Excel?

Tags: #<Tag:0x00007f0b02f50de8>

So copying cells with CTRL-C in HOT does this by default where if I copy a range of cells and paste it into excel, it will paste into the same range cells (ie: copy a row of 5 cells, I paste in Excel and get a row of 5 cells). How can I do this in HOT using a button that will get whatever the user has selected and do the same for Excel?

EDIT: I found and realized that you can access the CopyPaste plugin so I do what is already being done for CTRL-C, so I don’t have to reinvent the wheel. Problem is that my hotInstance.copyPaste does not have the copy(), paste(), or cut() functions, just the remaining ones, and hotInstance.getPlugin(‘CopyPaste’) returns undefined. Any ideas why?

Thank you. On Version 1.10.1

EDIT 2: No matter what I do, how many newlines or line break I add to my string before using document.execCommand(‘copy’), I can’t get a selection of cell data on different rows to appear on different rows on Excel the way CTRL-C can. What is Handsontable doing different?

Hi @vtruong74

sorry, but there are so many updates on this issue that I do not know the current state of it. Please let me know exactly what you would like the Handsontable to do and where is the issue.

Ok. So upon copying of a table cell or a group of cells (multiple rows and columns), I can paste these cells into excel and it’ll paste into the same number of rows and columns as I selected. This is for when I do CTRL-C. I want to be able to replicate this exact functionality but with a custom button.

Hi @vtruong74

Thank you for an update.

To copy selected cells programmatically you need to access copy method from the copyPaste plugin. Here is a demo http://jsfiddle.net/tg5LLuxt/

Let me know if you need anything else.

Thanks @aleksandra_budnik. This is for the latest versions of HOT right after CopyPaste removed its dependencies on ZeroClipboard? My HoT version is before that.

1.12.0 was the first version without the ZeroClipboard library.
Here https://docs.handsontable.com/pro/1.15.1/tutorial-release-notes.html is a full list of changes that each version adds.

Ok. I updated to the latest version. Should work fine now. Thanks!

Great! Thank you for an update.
I guess that we can close the issue but feel free to open a new one if needed.