Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
4155
How to print and Export to Excel contents of XamDataTree?
posted

How can i print (fully expanded) and export to excel the contents of a XamDataTree?

  • 34510
    Verified Answer
    Offline posted

    Hi Travis,

    In order to print the XamDataTree you will first need to render it into a bitmap and then print the resulting image.  RenderTargetBitmap should help with that.  In order to expand all the records though you will need to iterate through the XamDataTree.Nodes collection and set the IsSelected property to true.  Or you can use the IsExpandedMemberPath property to bind a Boolean property in your data to the node's expansion state and expand it through your data.  There is no automatic way to export the data to excel though.  This will need to be manually done but we have an Excel library that you can use for this.

    An alternative might be to use the XamTreeGrid instead.  This is a control we introduced in 15.1.  It's like a XamDataGrid but the data is displayed slightly different in order to produce a tree like structure.  It works with the DataPresenterExcelExporter as well so you can export it pretty easily.  It's also fairly simple to expand all the "nodes" by calling the ExpandAll method on the Records collection.  Printing is also easier as the WPF Reporting APIs will work with the tree grid.