Hi,
I am using RecordSelectorNumberType="VisibleIndex" in the field settings to display record number in xamdatagrid. When I export to excel, I want to export the record number. How can I achieve this.
Thanks,
Lala
Hello Lala, In order to export the records' selectors in XamDataGrid to Excel, an approach I can suggest you is to handle the RecordExporting, HeaderAreaExporting and the ExportEnding events of the DataPresenterExcelExporter instance. Inside the RecordExporting and the HeaderAreaExporting events, we can create an indentation for the records and the labels by incrementing the CurrentColumnIndex in order to make space for the record selector values in Excel. This way prior to ending the exporting operation, by handling the ExportEnding event, we can manually assign respective values for the cells in Excel, that act as record selectors. void exporter_RecordExporting(object sender, RecordExportingEventArgs e){ e.CurrentColumnIndex++;} void exporter_HeaderAreaExporting(object sender, HeaderAreaExportingEventArgs e){ e.CurrentColumnIndex++;} void exporter_ExportEnding(object sender, ExportEndingEventArgs e){ for (int i = 1; i <= XDG.Records.Count; ++i) { e.CurrentWorksheet.GetCell("A" + (i + 1).ToString()).Value = i; }} I have prepared an application where this behavior has been implemented. If you require any further assistance on this matter, please do not hesitate to ask.
Accessing the xamdatagrid like you are doing (XDG) is not an option. I have view and view model and the way we are tieing up the view to viewmodel, the viewmodel can not access the xamdatagrid by name. the object sender in this event is DataPresenterExcelExporter. Is there any other way to do this? Also I am exporting heirarical data and I want to show the record number onlly on the top level records. Another complexity is I have the option to export selected records only,