@@ -381,7 +381,7 @@ internal void CopyToClipboardInternal(bool includeHeaders)
381381 }
382382
383383 var package = new DataPackage ( ) ;
384- package . SetText ( GetSelectedContent ( includeHeaders ) ) ;
384+ package . SetText ( GetSelectedClipboardContent ( includeHeaders ) ) ;
385385 Clipboard . SetContent ( package ) ;
386386 }
387387
@@ -392,6 +392,26 @@ internal void CopyToClipboardInternal(bool includeHeaders)
392392 /// <param name="separator">The character used to separate cell values (default is tab).</param>
393393 /// <returns>A string of selected cell content separated by the specified character.</returns>
394394 public string GetSelectedContent ( bool includeHeaders , char separator = '\t ' )
395+ {
396+ var slots = GetSelectedCellSlots ( ) ;
397+
398+ return GetCellsContent ( slots , includeHeaders , separator ) ;
399+ }
400+
401+ /// <summary>
402+ /// Returns the selected cells' or rows' clipboard content as a string, optionally including headers, with values separated by the given character.
403+ /// </summary>
404+ /// <param name="includeHeaders">Whether to include headers in the output.</param>
405+ /// <param name="separator">The character used to separate cell values (default is tab).</param>
406+ /// <returns>A string of selected cell clipboard content separated by the specified character.</returns>
407+ public string GetSelectedClipboardContent ( bool includeHeaders , char separator = '\t ' )
408+ {
409+ var slots = GetSelectedCellSlots ( ) ;
410+
411+ return GetCellsContent ( slots , includeHeaders , separator , true ) ;
412+ }
413+
414+ private IEnumerable < TableViewCellSlot > GetSelectedCellSlots ( )
395415 {
396416 var slots = Enumerable . Empty < TableViewCellSlot > ( ) ;
397417
@@ -409,7 +429,7 @@ public string GetSelectedContent(bool includeHeaders, char separator = '\t')
409429 slots = [ CurrentCellSlot . Value ] ;
410430 }
411431
412- return GetCellsContent ( slots , includeHeaders , separator ) ;
432+ return slots ;
413433 }
414434
415435 /// <summary>
@@ -450,6 +470,11 @@ public string GetRowsContent(int[] rows, bool includeHeaders, char separator = '
450470 /// <param name="separator">The character used to separate cell values.</param>
451471 /// <returns>A string of specified cell content separated by the specified character.</returns>
452472 public string GetCellsContent ( IEnumerable < TableViewCellSlot > slots , bool includeHeaders , char separator = '\t ' )
473+ {
474+ return GetCellsContent ( slots , includeHeaders , separator , false ) ;
475+ }
476+
477+ private string GetCellsContent ( IEnumerable < TableViewCellSlot > slots , bool includeHeaders , char separator , bool isClipboardContent )
453478 {
454479 if ( ! slots . Any ( ) )
455480 {
@@ -458,9 +483,7 @@ public string GetCellsContent(IEnumerable<TableViewCellSlot> slots, bool include
458483
459484 var minColumn = slots . Select ( x => x . Column ) . Min ( ) ;
460485 var maxColumn = slots . Select ( x => x . Column ) . Max ( ) ;
461-
462486 var stringBuilder = new StringBuilder ( ) ;
463- var properties = new Dictionary < string , ( PropertyInfo , object ? ) [ ] > ( ) ;
464487
465488 if ( includeHeaders )
466489 {
@@ -481,7 +504,8 @@ public string GetCellsContent(IEnumerable<TableViewCellSlot> slots, bool include
481504 continue ;
482505 }
483506
484- stringBuilder . Append ( $ "{ column . GetCellContent ( item ) } { separator } ") ;
507+ var content = isClipboardContent ? column . GetClipboardContent ( item ) : column . GetCellContent ( item ) ;
508+ stringBuilder . Append ( $ "{ content } { separator } ") ;
485509 }
486510
487511 stringBuilder . Remove ( stringBuilder . Length - 1 , 1 ) ; // remove extra separator at the end of the line
0 commit comments