Properly format table text for clipboard pasting into a spreadsheet

I have a table in my (macOS) app. The user can copy the entire table and paste it into a spreadsheet using Command-C to copy the table contents. That’s a menu function provided by the control, so we don’t have to code anything and it works fine.

However, in my app the user can also select just one row, or just one column, and copy that to the clipboard. It appears that I have to handle those cases, because Command-C always copies the entire table, not what’s selected. I format the text using EndOfLine and Tab. Pasting into Numbers absolutely doesn’t work. Everything always goes into one cell no matter what I do with the text. Seems like this used to work, but maybe I’m remembering incorrectly, or maybe Numbers is just awful, or both.

In any case, my question is: what is happening differently under the hood when it’s working according to the menu function in the control, as opposed to my formating that’s not working? Is there a RawData URI option I’ve missed? Thanks in advance for any help.

You can use ClipboardViewer to find out. Last I knew it was bundled with Xcode. (Not at my desk sorry)

Clipboard data type? Maybe.

We will know more once you check ClipboardViewer.

1 Like

Thanks, my first thought was to find something that would show me the difference on the clipboard itself, but searching led me to nothing, so I asked here. This is the first time I’ve heard of something called ClipboardViewer. I don’t see it anywhere, searching doesn’t find it, and AI tells me it doesn’t exist (which is hilarious, because AI is usually telling me something exists when it doesn’t).

Clipboard Viewer is part of macOS. At least it says it says Apple as copyright. You don’t have that installed?

1 Like

And if the app is not installed you can use Thomas’ app. See Thomas Tempelmann | ShowClipboards for macOS

1 Like

Thank you – Clipboard Viewer is not on my system, so I suppose it must be an option installed from within Xcode (which I do have installed and keep up to date since I need the command-line tools, but I don’t use the XCode IDE). I’ll try Thomas Tempelmann’s app now …

Your issue may be related to using the wrong EndOfLine. Have you tried using different flavours?

1 Like

Thomas’ app helped me solve this. When the whole table is copied, it’s all normal utf8 text with TAB chr(9) separating columns. The difference is the EOL character. The trick is to use chr(10) LF. When you use that character, Numbers (meaning Apple’s spreadsheet app) will recognise the text as a table so it will paste correctly.

Thanks everybody :slight_smile: