Hello,
I am able to export the data to excel fine. But I am not able to set Excel styles using code or using Format Settings & Binding.
I have tried the following code (in DataPresenterExcelExporter_CellExporting ), but it fails as I am binding to the style resource.
Setter bgSetter = cellStyle.Setters.Where(s => s is Setter && (s as Setter).Property.Name.Equals("Background")). FirstOrDefault() as Setter;
if (bgSetter != null) { e.FormatSettings.FillPatternForegroundColor = (bgSetter.Value as SolidColorBrush).Color; } The problem is, since I am data binding using Setter (<Setter Property="Background" Value="{Binding Path=DataItem.DisplayNameBackgroundColor}" /> ), the value is not soldcolorbrush and the code above is throwing an error.I also tried using the following code in xaml, but it also did not work:
<igExcelExporter:FormatSettings BorderColor="{Binding Path=DataItem.BackgroundColor}" ></igExcelExporter:FormatSettings>I would appreciate your assistant. Also, what is the best / recommended way to export to excel without duplicate DataPresenter Styles?Regards,Sandy
Hello Sandy,
I am just checking if you require any further assistance on the matter.
Hi Yanko,
I have looked at the sample solution. I am able to export the color if I use the same syntax as sample. But I am trying to bind the color to a property of the object. Please let me know if this is possible.
<igExcelExporter:FormatSettings FillPatternBackgroundColor="{Binding Path=DataItem.FundNameBackgroundColor}"></igExcelExporter:FormatSettings>
Here is how I am binding the grid:
<igDP:XamDataGrid DataSource="{Binding MyItems}" Name="xamDataGrid1" HorizontalAlignment="Center" VerticalAlignment="Top" >
Is it possible to bind the Excel export to a Field instead of hard-coding it?
Great Thank you. The sample looks like what I am looking for. I will look at it and let you know if I need any further assistance.
Thank you,
Sandy