1. Peter Thiem
  2. PowerBuilder
  3. Monday, 4 April 2022 12:38 PM UTC

Hi Community,

In this application, the users have a problem cutting and pasting from Excel.

The paste operation is failing to paste data into "Datawindow Single Line Edit" fields.

Afaict, it is because the clipboard of the Excel cell contains a CRLF  data, and the single line edit field is rejecting the paste operation.

These fields are specifically string data types, in data windows, single line (no vertical scrollbars), the edit style is "Edit" (not edit mask).

That is...

1. If you cut the “WHOLE CELL” from Excel, and paste into a "Datawindow Single Line Edit" field, then nothing happens, and a rejection chime sounds.

2. If you cut the value (by selecting the text within the cell) from Excel, and paste into a "Datawindow Single Line Edit" field, then the data will paste.

What is the best way to solve this problem - that is - so the users can cut and paste easily from excel into these data fields?

Cheers, Peter.

P.S.

  • So far i've looked at hooking into the pfc_u_dw.pfc_paste event, and replacing the clipboard with trimmed text. Also capturing control-v with a hidden menu item and routing to pfc_paste. Is there a better way..?
  • The users have come over from the dotnet 12.5 version of the application, and were accustomed to pasting whole cells from Excel, it saves them a click or two, which they like .
  • Note, if you paste a Cell that has content that is longer than the limit, the a truncated paste will succeed as the CRLF are truncated off.

 

Accepted Answer
René Ullrich Accepted Answer Pending Moderation
  1. Monday, 4 April 2022 13:38 PM UTC
  2. PowerBuilder
  3. # Permalink

Hello Peter,

I don't know what is the best way. As you wrote you can do it like PFC and trim the CRLF.

If you don't want to use you can also use the datawindow key event (EventId pbm_dwnkey) with code like this:

IF key = KeyV! and keyflags = 2 THEN
	// on CTRL+V replace the clipboard with a trimmed value
	::clipboard(trim (::clipboard(), true))
END IF

 

Comment
There are no comments made yet.
mike S Accepted Answer Pending Moderation
  1. Monday, 4 April 2022 13:27 PM UTC
  2. PowerBuilder
  3. # 1

you have to write powerscript to handle excel's added CR/LF 

 

IMO, it is not really a PB problem, but rather an excel idiosyncrasy - other microsoft products have the same problem with paste from excel

 

Comment
There are no comments made yet.
Peter Thiem Accepted Answer Pending Moderation
  1. Thursday, 28 April 2022 02:21 AM UTC
  2. PowerBuilder
  3. # 2

Thanks Rene,

This seems to be a good way to capture Control-V.

I'll hook this together with a change to the pfc_u_dw.pfc_paste, so that the right mouse button context menu is also handled.

I also added code to detect if a single line field, so wont affect multiline fields.

Cheers, Peter.

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.