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
220
How to align data in columns same as the alignment in WebDataGrid?
posted

We export data from WebDataGrid using WebExcelExporter. In the grid, we right align all the columns which have numeric data (by updating the grid CSS). However, when we export this data to excel, the horizontal alignment setting is not exported.

Please let us know how to fix this. We need to be able to format header, data rows as well as summary row (if any).

Thanks!

Parents
No Data
Reply
  • 2671
    Offline posted

    Hello Sumit,


    The WebExcelExporter should pick up styles automatically as the EnableStylesExport Property is true by default. The fields and their headers all have CssClass peroperties:

                    <ig:BoundDataField DataFieldName="PostalCode" Key="PostalCode" CssClass="rightAlign">

                        <Header Text="PostalCode" CssClass="redHeader">

                        </Header>

                    </ig:BoundDataField>

    Which will pick up the following styles:

            tbody>tr>td.rightAlign {

                text-align:right;

                background-color:red;

            }

            .redHeader {

                text-align:right;

                background-color:#b60101;

            }

    As for summaries the row can accept global setting for all cells:

    <ig:SummaryRow SummariesCssClass="summaryStyle">

                  …

    </ig:SummaryRow>

    There seems to be some preference in parsing the styles on the page that I want to investigate further, but I did find the exporter picks up a global class, so something like this works:

            th.summaryStyle{

                /*client override*/

                background-color: #00c1ff;

            }

            .summaryStyle{

                 /*export style*/

                background-color: #00c1ff;

            }

    The SummaryRow also has SummarySettings that can accept CssClass for a single summary cell configuration.

    I’ve attached a sample that successfully exports column, header and summary styles.

    Let me know if this helps and if I may be of further assistance.


    Regards,
    Damyan Petev
    Associate Software Developer
    Infragistics, Inc.

    ExcelExporterGridStyles.zip
Children