first_page

XamDataGrid: Drag-Drop from Excel to WPF

The point of this post is to reintroduce System.Windows.DataObject.OleConverter (which I assume is an old, Don-Box-era friend in a relatively new .NET wrapper) and not to confirm that the XamDataGrid supports Excel and/or Object Linking and Embedding (OLE) by default. This is what happens to the XamDataGrid I currently work with (which does have custom, Excel-related behaviors attached): Drag-Drop from Excel to WPF

Debug is shows that the Range of cells selected for Drag is boxed in a System.Windows.DataObject, which has a _innerData field of type System.Windows.DataObject.OleConverter. Meanwhile, back in Excel we have this message: Drag-Drop from Excel to WPF

Eventually, I see that I need to call System.Windows.DataObject.GetFormats() which returns:

{string[25]}
    [0]: "EnhancedMetafile"
    [1]: "System.Drawing.Imaging.Metafile"
    [2]: "MetaFilePict"
    [3]: "Bitmap"
    [4]: "System.Drawing.Bitmap"
    [5]: "System.Windows.Media.Imaging.BitmapSource"
    [6]: "Biff12"
    [7]: "Biff8"
    [8]: "Biff5"
    [9]: "SymbolicLink"
    [10]: "DataInterchangeFormat"
    [11]: "XML Spreadsheet"
    [12]: "HTML Format"
    [13]: "Text"
    [14]: "UnicodeText"
    [15]: "System.String"
    [16]: "CSV"
    [17]: "Hyperlink"
    [18]: "Rich Text Format"
    [19]: "Embed Source"
    [20]: "Object Descriptor"
    [21]: "Link Source"
    [22]: "Link Source Descriptor"
    [23]: "Link"
    [24]: "Format129"

This, then, allows me to call System.Windows.DataObject.GetData("CSV") which returns:

",MKT_VAL,PORTFOLIO_MANAGER,ACCOUNT_NAME\r\nXXXX,\" $224,679,351,495.25 \", Gross , XXXX Total Return Fund \r\n701,, Cudzil , XXXX Mortgage-Backed Securities Fund \r\nXXXX,\" $3,769,059,862.42 \", Kiesel , XXXX Investment Grade Corporate Portfolio \r\n"

…where XXXX is added for this public demonstration.

https://github.com/BryanWilhite/