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
1435
DataPresenterExporter does not export a styled CellValuePresenter
posted

Hello,

I styled a CellValuePresenter ContentTemplate. When exporting the XamDataGrid, the ECar make does not export properly.

Please see attached Demo Project. Double Click on the XamDataGrid to export.

Thank you

Demo.zip
Parents
No Data
Reply
  • 34810
    Verified Answer
    Offline posted

    Hello User201,

    I have taken a look at the sample project you have attached, and this behavior is expected. The DataPresenterExcelExporter does not really care about the Content of the cells that are presented, but rather, the actual underlying Value of that cell. You are currently using a Name-mapping to your ECar property of your underlying Employee data item, and so the actual underlying Value of your cell is the Car item that is shown in the resultant Excel workbook. There are a couple of things you can do to resolve this.

    The first thing I would recommend is to use an AlternateBinding for your Field. This was put into place as a sort of "Unbound" functionality that allows complex bindings, since the Name-mapping does not. If you declare AlternateBinding = "{Binding ECar.Make}" on your Field on your end, you will be able to export correctly.

    Another option is to handle the CellExported event of the DataPresenterExcelExporter. This will allow you to obtain the WorksheetCell that has exported, along with the corresponding Record that owns the cell that created it and the Field that owns that cell. From the Record property of the event arguments, you can get the DataRecord element, and from its DataItem property, the underlying Employee element that makes up that record. You can then change the WorksheetCell.Value property to the value that you wish to export.

    I have attached a modified version of the sample project you sent to demonstrate both methods mentioned above. I hope this helps.

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer

    Demo.zip
Children