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
1405
WebExcelExporter
posted

I have webhierarchicaldata grid with two child grids. When I export the grid to excel using cellexporting event it always picks the alternate rows. Can anyone please suggest what is wrong in the code I am using:

if (!e.IsHeaderCell && !e.IsFooterCell )
            {
                int index = GetIndex(System.Convert.ToString(e.Worksheet.Rows[0].Cells[e.CurrentColumnIndex].Value));
                GridRecordItem item =  WebHierarchicalDataGrid1.Rows[e.CurrentRowIndex - 1].Items[index];

                if (item.Column.GetType().Name == "TemplateDataField")
                {
                    TemplateDataField field = item.Column as TemplateDataField;
                    HtmlAnchor proj_id = (HtmlAnchor)item.FindControl("demo");
                    if (proj_id != null)
                    {
                        e.WorksheetCell.Value = proj_id.Title;
                        e.Cancel = true;
                    }
                }
                else
                {
                    e.WorksheetCell.Value = item.Text;
                    e.Cancel = true;
                }
            }

 

Thanks,

Megha

Parents
No Data
Reply
  • 8160
    posted

    Hello Megha,

    Probably the logic in this method is wrong. Does GetIndex return the correct index?

Children