This question is locked. New answers and comments are not allowed.
When I cancel the grid_ElementExporting event for all cells in the row, but not for the row itself, it leaves an empty record in Excel file. Is there any way to eliminate these empty records? Please advise. Thanks.
grid_ElementExporting()
grid_ElementExported()
resulting Excel file - see attached picture.
grid_ElementExporting()
private
void
grdDataView_ElementExporting(
object
sender, GridViewElementExportingEventArgs e)
{
if
(e.Element == ExportElement.HeaderCell || e.Element == ExportElement.Cell)
e.Cancel =
true
;
}
grid_ElementExported()
private
void
grdDataView_ElementExported(
object
sender, GridViewElementExportedEventArgs e)
{
if
(e.Element == ExportElement.HeaderRow)
{
e.Writer.Write(String.Format(@
"<td>{0}</td>"
,
"Plan Code"
));
}
if
(e.Element == ExportElement.Row)
{
JobDetailModel obj = e.Context
as
JobDetailModel;
e.Writer.Write(String.Format(@
"<td>{0}</td>"
, obj.PlanCode));
}
}
resulting Excel file - see attached picture.