Reputation: 771
I'm exporting gridview to excel using ClosedXML, I want my output to have a one column apart. Like this.
This is my code for the gridview header part.
for (col = 0; col < headerCount; col++)
{
worksheet.Cell(3, current + 1).Value = GridView1.HeaderRow.Cells[col].Text;
}
Note: My gridview column count is dynamic.
Upvotes: 0
Views: 331
Reputation: 4839
Try this:
for (col = 0; col < headerCount; col++)
{
worksheet.Cell(3, current * 2 + 1).Value = GridView1.HeaderRow.Cells[col].Text;
}
Upvotes: 1