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
195
Export To Excel with Grid Style
posted

Hi All,

My grid uses alternate row colors, some columns are icons. How to export those data to excel with alternate background colors?
One approch came to my mind, to achieve this requirement partially, is to make use of RecordExporting event as shown below
 
 int count = 1;
        void export_RecordExporting(object sender, RecordExportingEventArgs e)
        {
            System.Drawing.Color rowColor;
            if (count % 2 == 0)
            {
                rowColor = System.Drawing.Color.Gray;
            }
            else
            {
                rowColor = System.Drawing.Color.Transparent;
            }
            e.Workbook.Worksheets[0].Rows[count].CellFormat.FillPatternBackgroundColor = rowColor;
            count++;
        }

Any thoughts is greatly appreciated

regards
Ajosh

 

Parents
No Data
Reply
  • 7305
    Suggested Answer
    posted

    Ajosh,

    I would probably suggest similar approach what you already know as there is no built-in functionality to set an alternating style.

    Sincerely,

    Sam

Children
No Data