Excel clipboard data

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
jdorlon
Posts: 15
Joined: Wed Jan 13, 2010 7:24 pm

Excel clipboard data

Post 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
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Excel clipboard data

Post by larsa »

Hello

You can try:

Code: Select all

XLS.Clipboard.PasteFromClipboard(Sheet,Col,Row);
Lars Arvidsson, Axolot Data
jdorlon
Posts: 15
Joined: Wed Jan 13, 2010 7:24 pm

Re: Excel clipboard data

Post 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?
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Excel clipboard data

Post 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.
Lars Arvidsson, Axolot Data
jmarder
Posts: 2
Joined: Thu Sep 22, 2022 6:56 am

Re: Excel clipboard data

Post 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().
Post Reply