Page 1 of 1

Excel clipboard data

Posted: Fri Apr 16, 2021 6:22 pm
by jdorlon
Hello,

This question is not really related to XLSReadWrite, but maybe XLSReadWrite can help.

In my application, I have TDataSets and TDBGrids. We have a feature that allows the dataset contents to be exported to clipboard (plain text, tab delimited) and it works fine.

However, if I paste into MS Word or Teams, it doesn't make a nice table, as if I had copied/pasted from Excel. I have tried exporting to HTML clipboard format with a HTML Table, but that doesn't do it either.

Is there a way that I can use XLSReadWrite to copy data to the clipboard in the same format that Excel does?

Thanks

John

Re: Excel clipboard data

Posted: Sat Apr 17, 2021 10:46 am
by larsa
Hello

You can try:

Code: Select all

XLS.Clipboard.PasteFromClipboard(Sheet,Col,Row);

Re: Excel clipboard data

Posted: Wed Apr 21, 2021 1:47 pm
by jdorlon
I saw that, but doesn't that command paste clipboard contents INTO the XLS file?

That's not what I am trying to do.

I want to copy data from a grid/dataset into the clipboard and paste into other MS products like Word or Teams, using the same format that I would have if I copied from Excel into Word or Teams.

Do you have any advice on that?

Re: Excel clipboard data

Posted: Thu Apr 22, 2021 4:44 pm
by larsa
Hello

Sorry, XLSReadWriteII can't paste to the clipboard. But Excel (don't know if it works with other apps) will populate the cells if you paste a list with values separated with tabs and the lines ended with CR/LF.

Re: Excel clipboard data

Posted: Thu Sep 22, 2022 7:03 am
by jmarder
But Excel (don't know if it works with other apps) will populate the cells if you paste a list with values separated with tabs and the lines ended with CR/LF.
Since we cannot know to which application the user will finally paste the copied data, we are currently copying it as HTML and as CSV. Unfortunately, Excel prefers the HTML over the CSV format that the HTML format does not produce good results.

And both formats have the problem that they do not properly separate the value and the unit, so that Excel fills them as text and you cannot calculate with them. This works fine if we write an Excel file, but users are complaining that this takes far more clicks than the clipboard way.

Looking at the code in TXLSClipboard.PasteFromClipboard() it shoudn't be too difficult to write a counterpart CopyToClipboard().