odlan yer
odlan yer

Reputation: 771

export gridview to excel using closed xml with 1 column apart

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.

Upvotes: 0

Views: 331

Answers (1)

Francois Botha
Francois Botha

Reputation: 4839

Try this:

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

Upvotes: 1

Related Questions