Paste Columns into Numbers

How can I format the text in my clipboard so that it will paste into Apple Numbers as multiple columns.

If I create a clipboard with “Hello World”, and paste it into Excel it pastes properly as two columns.

Pasted into Numbers it appears as single cell.

If I write the same text in TextEdit (or any other Apple app) and copy and paste it into Numbers, it works. I’m guessing it’s saving another kind of non text clipboard information.

Pasting the text (that works) from TextEdit and the text from my app (which doesn’t), into BBEDIT with invisibles turned on shows them to be identical.

(Yes, slightly off topic as this is not Xojo specific however Googling this resulted in lots of noise and no joy.)

I just fired a Xojo generated application with a ListBox, copied all the document contents (22 Rows !), then Paste into Numbers:

every ListBox Cell appears in Numbers cells.

Edit: I removed some typos errors.

When you paste column/row formatted text into numbers, you should see a popup with “Adjust settings” button.
You might need to adjust the settings to make the pasted data look correct.

The correct format is to separate each cell with a tab: chr(9), and each row with an EndofLine

[quote=488103:@Emile Schwarz]I just fired a Xojo generated application with a ListBox, copied all the document contents (22 Rows !), then Paste into Numbers:

every ListBox Cell appears in Numbers cells.

Edit: I removed some typos errors.[/quote]

Odd. I just created a new Xojo app with a listbox with two columns and two sample rows. Ran it and copied it to Numbers and it all came into the same cell. Tried in both Mojave and Catalina.

What OS are you running?

[quote=488104:@Jeremie Leroy]When you paste column/row formatted text into numbers, you should see a popup with “Adjust settings” button.
You might need to adjust the settings to make the pasted data look correct.

The correct format is to separate each cell with a tab: chr(9), and each row with an EndofLine[/quote]

I don’t seem to get that popup but in any case wouldn’t want my users to have to figure it out.

However if I use the below code, it pastes unfortunately as one cell.

[code]Dim c As Clipboard

// Create a new instance of the clipboard
c = New Clipboard

// Put the text from the TextArea into the clipboard
c.SetText(“Hello” + Chr(9) + “World” + EndOfLine)

// Close the clipboard when finished
c.Close[/code]

Eureka! Apparently Numbers expects a properly formatted RTF clipboard. Otherwise it pastes it in a single column as plain text. This code generates a clipboard that Numbers is happy with:

[code]Dim c As Clipboard

// Create a new instance of the clipboard
c = New Clipboard

// Add RTF Data
Dim rtf As String = “{\rtf1\ansi\deff0 {\fonttbl {\f0 System;}}\f0\fs24 Hello, \tab World!}”
c.AddRawData(rtf, “public.rtf”)

// Put the text from the TextArea into the clipboard
c.SetText(“Hello” + Chr(9) + “World” + EndOfLine)

// Close the clipboard when finished
c.Close[/code]

I use old stuff (El Capitan)…

and the Clipboard holds (fromXojo ListBox Copy):

{{«class utf8», 2441}, {«class ut16», 4562}, {string, 2242}, {Unicode text, 4560}}

Happy you find a way to get what you need.

Nota:
In the Script Editor, paste:
return clipboard info

and run it to get clues of what you really have in the Clipboard.

Sometimes the correct data have to appears first in the line to work (images from Firefox to Xojo Canvas for example; a Paste in Preview followed with a Copy get data Xojo Canvas accept…)

@Emile Schwarz Thanks! Wish I could get that working. Supporting ascii characters in RTF is a royal pain and this would be much simpler.

Did you tried Paste to OpenOffice ?

What happens when you Paste into Raw Text mode of TextEdit ?

What says the Script Editor when you use the standard ListBox Copy ?

FileCopy MenuHandler, here is set in a ListBox subclass, and the core code is:

[code]For LoopIdx = RowCnt DownTo 0

If Me.Selected(LoopIdx) Then
  // Copy the Row Contents in the Clipboard
  TheData = Me.Cell(LoopIdx,-1) + EndOfLine + TheData
End If

// Avoid 1, Infinite Loop
If UserCancelled Then Exit

Next

// Place the Selected Rows contents into the Clipboard
Clip.Text = TheHead + TheData // The Head holds the Header string or nothing

// Export the Clipboard
Clip.Close

// Handled !
Return True[/code]

I notice this seems to copy from a listbox with multiple rows but one column. I’m pasting rows OK. It’s the columns that’s the problem.

WRONG:
-1 = all columns !

I do not recall where in the documentation this is.

ListBox1.Cell(-1,-1) return the whole ListBox Rows.

You’re right. It does copy the whole row with tabs. I didn’t know that.

Alas, in Mojave/Catalina, it still pastes into Numbers as a single column so it’s back to converting high characters to RTF format.