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
310
Export Excel with XamDataGrid Style/Background
posted

Hi,

I am trying to export my data from XamDataGrid to Excel using DataPresenterExcelExporter. I know that I can manually set colors and styles on CellExporting, but what I wanted to achieve is toautomaticallyexport also the grid's colors and format (as I have some sort of conditional formatting implemented in the grid).

Is there a possible way of doing this in infragistics?

Thanks!

  • 17475
    Offline posted

    Hello,

    The formatting of the grid when exported to Excel could be specified in the XAML. It could be set to specific field using the ExcelCellFormatSettings:

                      

     <igDP:Field Name="OrderID">
                            <igDP:Field.Settings>
                                <igDP:FieldSettings>
                                    <igExcelExporter:DataPresenterExcelExporter.ExcelCellFormatSettings>
                                        <igExcelExporter:FormatSettings BorderColor="#FF999999"
                                                                        FontColor="Gray"
                                                                        FontWeight="Bold"
                                                                        FontFamily="Arial"
                                                                        FillPattern="Solid"
                                                                        FillPatternBackgroundColor="#FFDBEEF3"
                                                                        FillPatternForegroundColor="#FFDBEEF3"
                                                                        HorizontalAlignment="Right">

                                           
                                            <igExcelExporter:FormatSettings.FontSize>
                                                <igWindows:DeviceUnitLength Value="12"
                                                                            UnitType="Point" />
                                            </igExcelExporter:FormatSettings.FontSize>
                                        </igExcelExporter:FormatSettings>
                                    </igExcelExporter:DataPresenterExcelExporter.ExcelCellFormatSettings>
    </igDP:FieldSettings>
                            </igDP:Field.Settings>
                        </igDP:Field>


    You can also specify the label and summaries by specifying the ExcelLabelFormatSettings and ExcelSummaryCellFormatSettings.

    If the style should be set on cell basis, the best approach is to use the CellExporting event to apply the custom format.

    Let me know if you have any other questions.