Programmatically create borders in Excel
<p>I need to know how to create borders in excel for header in the for loop based on individual cells. Below is my code to export to excel </p>

<pre><code>for (int i = 1; i &lt; dataGridView1.Columns.Count + 1; i++)
{
worksheet.Cells[5, i] = dataGridView1.Columns[i - 1].HeaderText;
worksheet.Cells[5, i].HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;
worksheet.Cells[5, i].Font.Bold = true;                    
}
</code></pre>