When copying data from the grid, either using Ctrl+C or calling the CopyToClipboard method, if the data contains carriage returns in any of the cells then if this is pasted into Excel then additional rows are created for each line of text in the cell. Is it possible for the clipboard to contain a version of the copied data in a format such that when pasted into Excel it displays correctly, i.e. the text is in a single cell rather than split over multiple rows?
We have closed this ticket because another page addresses its subject:
Support Excel clipboard format when using Ctrl+C in the grid or using the CopyToClipboard method.
Hello Stephen.
Thank you for your message.
Unfortunately, there is no way to achieve the desired result. When the CopyToClipboard method is called, we write data to the Clipboard as text:
procedure TcxCustomGridTableView.CopyToClipboard(ACopyAll: Boolean); procedure AddHeaders; var I: Integer; begin for I := 0 to FCopyToClipboardItems.Count - 1 do FCopyToClipboardStr := FCopyToClipboardStr + TcxCustomGridTableItem(FCopyToClipboardItems[I]).GetAlternateCaption + ColumnSeparator; if FCopyToClipboardItems.Count <> 0 then FCopyToClipboardStr := Copy(FCopyToClipboardStr, 1, Length(FCopyToClipboardStr) - Length(ColumnSeparator)); FCopyToClipboardStr := FCopyToClipboardStr + EndOfLine; end; begin ... GetItemsListForClipboard(FCopyToClipboardItems, ACopyAll); FCopyToClipboardStr := ''; if OptionsBehavior.CopyCaptionsToClipboard then AddHeaders; ... DataController.ForEachRow(not ACopyAll, CopyForEachRowProc); ... if (Length(FCopyToClipboardStr) >= Length(EndOfLine)) and (Copy(FCopyToClipboardStr, Length(FCopyToClipboardStr) - Length(EndOfLine) + 1, Length(EndOfLine)) = EndOfLine) then SetLength(FCopyToClipboardStr, Length(FCopyToClipboardStr) - Length(EndOfLine)); ... Clipboard.AsText := FCopyToClipboardStr;
However, MS Excel uses different clipboard formats to process data correctly, take carriage returns into account, and copy formatting and styles. That is why you see such behavior.
Hopefully, my explanation is clear.
Best regards,
Ingvar.
Hi
Is this something you may consider implementing in a future version, i.e. place both a plain text format and Excel format on the clipboard?
Regards
Stephen
Hello Stephen.
Thank you for the response.
You can post a separate suggestion about supporting clipboard operations using MS Excel format. Our developers will consider it and will possibly implement it in future versions of our controls.
However, I cannot give you any precise time frame on when that request may be implemented. Fortunately or not, our TO-DO list is very long, so we have to decide which features to implement first, and which ones to delay. In any case, we try to take all requests into account when scheduling our development.
Best regards,
Ingvar.
Hi
I have logged a separate suggestion issue for this as you suggested.
Regards
Stephen
Hello Stephen.
Thank you for the request. I've forwarded it to our developers for further processing. You'll receive an automatic message once the status of this issue is changed.
Please feel free to contact us if you have any questions regarding our controls. We'll do our best to find a solution for you.
Best regards,
Ingvar.