Paste column into grid

Using (or providing) components based on the "Win32" framework

Paste column into grid

Postby Hannu on Mon Jan 31, 2011 11:37 am

I'd like to copy a column from Excel to clipboad and paste it into a column in Dyalog grid starting from a selected cell. But it is transposed to a row. Only when the target region in the grid is preselected it goes to the wrigth place. Is it possible to change this default Excel -> Dyalog grid pasting method? Thanks in advance!
Hannu
 
Posts: 5
Joined: Tue Jan 25, 2011 1:21 pm

Re: Paste column into grid

Postby kai on Mon Jan 31, 2011 12:22 pm

Presumably it's not. When you inspect the clipboard after the copy you will find that there is no way to tell whether the data is a column or a row. Nothing you can do about this. Well, you could start pestering Bill...
User avatar
kai
 
Posts: 137
Joined: Thu Jun 18, 2009 5:10 pm
Location: Hillesheim / Germany

Re: Paste column into grid

Postby uwejanza on Tue Feb 01, 2011 4:30 pm

When an application copies data into the clipboard it may provide the data in several formats simultaneously. Every application is allowed to add data to the clipboard in it's own proprietary format, or even in several formats, containing more or less information. At least the application's programmers have the choice to do so.

So data you find in the clipboard may or may not contain shape information. The only clipboard format common to (almost) all applications is plain text. This format does not know about columns.

Of course, in Excel an additional proprietary clipboard data format is provided, so a user of Excel can copy data from one instance of Excel to the next instance of Excel in a way that preserves shape. For this purpose, Excel simply has to first check the clipboard for data in it's own proprietary format.

The challenge for an application that wants to paste data from the clipboard is to guess which of the data formats provided in the clipboard at the moment is most appropriate.
uwejanza
 
Posts: 19
Joined: Tue Mar 09, 2010 2:01 pm
Location: Nürnberg, Germany

Re: Paste column into grid

Postby kai on Tue Feb 08, 2011 2:57 pm

Although Uwe is correct in what he's saying it might be misleading:

The information in which formats data is available on the clipboard is provided by the "Formats" property. Naturally, Dyalog only supports standard formats. So any proprietary formats left behind by any other application is not available to an APL programmer, at least not without []NA calls.

It's understandable that the text format does not provide any information regarding shape, but what it less understandable is why the array property doesn't come with it when only a single row or a single column got copied.

For example:

      'cl' ⎕wc'Clipboard'
⍝ after copying 3 rows and 2 columns
⍴cl.Array
3 2
⍝ after copying 3 rows and ONE column
⍴cl.Array
3


That is simply rubbish.
User avatar
kai
 
Posts: 137
Joined: Thu Jun 18, 2009 5:10 pm
Location: Hillesheim / Germany

Re: Paste column into grid

Postby Phil Last on Tue Feb 08, 2011 6:41 pm

I don't have msexcel but I do have open-office calc.

copy 3 rows by 1 column.

Then in APL:
   ⍴CL.Array
3

copy 1 row by 3 columns.

   ⍴CL.Array
1 3

if ooo is the same as excel then I guess you need:

   ⍴⍪CL.Array
User avatar
Phil Last
 
Posts: 628
Joined: Thu Jun 18, 2009 6:29 pm
Location: Wessex

Re: Paste column into grid

Postby uwejanza on Wed Feb 09, 2011 10:06 am

I just repeated Phil's extension to Kai's example with Excel:

'cl' ⎕wc'Clipboard'
⍝ Copy 1 row and 3 columns into the clipboard
⍴cl.Array
1 3
⍝ Copy 3 rows and 1 column into the clipboard
⍴cl.Array
3

Same result as with ooo. Seem like for once in my life Bill is not the one to be pestered.
uwejanza
 
Posts: 19
Joined: Tue Mar 09, 2010 2:01 pm
Location: Nürnberg, Germany

Re: Paste column into grid

Postby Phil Last on Wed Feb 09, 2011 10:19 am

The fact that there is a difference between a column vector and a single row means that there is no ambiguity. Inserting monadic comma-bar (⍪) forces a vector to be a 1 column matrix. This is the solution the original poster requires.
User avatar
Phil Last
 
Posts: 628
Joined: Thu Jun 18, 2009 6:29 pm
Location: Wessex


Return to Windows: GUI, COM/OLE/ActiveX

Who is online

Users browsing this forum: No registered users and 1 guest