I want to paste the contents of a DataGridView in Excel. However, the content of a column, because each row has extra blanks at the end of the string, makes this column much longer than the content.
Whereas I have this code to select what I want to paste:
dgv1.SelectAll()
dgv1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
Clipboard.SetDataObject(dgv1Operaciones.GetClipboardContent())
Sheet.Range("A5").Select()
Sheet.Paste()
How can I apply Trim () in this case, so that the affected column stops lengthening more than it should? Thanks in advance.