0

I'm exporting gridview to excel using ClosedXML, I want my output to have a one column apart. Like this. enter image description here

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.

odlan yer
  • 721
  • 1
  • 7
  • 15

1 Answers1

1

Try this:

for (col = 0; col < headerCount; col++)
{
    worksheet.Cell(3, current * 2 + 1).Value = GridView1.HeaderRow.Cells[col].Text;
}
Francois Botha
  • 4,520
  • 1
  • 34
  • 46