There are few things that I am doing before exporting the grid to excel. I will try to explain those in a bit. The problem that I am running into that the
Grid.HeaderRow.Cells[1].Text is "".
Apparently this has something to do with the SortExpression. Does anyone know if SortExpression is used, the Column Headers are blank. Any solutions.
Here is what I am doing (Not that what I am doing matters)
All columns have a SortExpression attached. When I try to get the header row text, it returns blank.
This is something I found link. Seems like this user also has the same problem as I have. Please read the reply at the botton
Please help. Thanks.
Ha! Answering my own question!
You have to do:
for(int i=0; i<grid.Columns.Count; i++)
{
var headertext = grid.Columns[i].HeaderText;
dt.Columns.Add(new DataColumn(headertext));
}
and not cell.