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
125
DataPresenterExcelExporter Binding
posted

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

Parents Reply Children
No Data