无法将MS-Excel列粘贴到SWT的文本小部件中

我有SWT文本小部件,它是用SWT.SINGLE样式创build的

 Text myTextControl = new Text(shell, SWT.SINGLE); 

现在,当我尝试从MS-Excel复制列时,只有该选定列的第一个被粘贴到Text小部件而不是整个列。
我明白,当我用SWT.MULTI创buildText小部件时,我可以将整个excel列粘贴到小部件中,但它不会在单行中。

以前,我使用Swings JTextField ,在这种情况下,无论何时我使用粘贴MS-Excel列(使用CTRL-V),整个Excel列都被作为JTextField的一行粘贴。
我正在为SWT文本小部件寻找同样的function。

问题是Excel在选定列中的每个单元格之后放置的新行字符。 Text.SINGLE然后识别粘贴文本的行结束并修剪它。

此代码获取粘贴事件,并replace所选的所有新行字符

 import org.eclipse.swt.SWT; import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; public class PasteModify { private final String lineReplaceString = ", "; public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout(SWT.VERTICAL)); Text tfPaste = new Text(shell, SWT.BORDER); tfPaste.setText("paste excel column here"); tfPaste.addListener(SWT.Verify, new Listener() { @Override public void handleEvent(Event event) { event.text = event.text.replace("\n", PasteModify.this.lineReplaceString); } }); shell.setBounds(50, 50, 300, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } }