I identified the code slowing down the process as this one (where I'm filling the cells):

What I'm doing here is basically loading some data from a database using a DataSet.

```
Microsoft.Office.Interop.Excel.Range range1 = null;
Microsoft.Office.Interop.Excel.Range cell1 = null;
Microsoft.Office.Interop.Excel.Borders border1 = null;

for (i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
{
    int s = i + 1;
    for (j = 0; j <= ds.Tables[0].Columns.Count - 1; j++)
    {
        data = ds.Tables[0].Rows[i].ItemArray[j].ToString();
        xlWorkSheet.Cells[s + 1, j + 1] = data;

        range1 = xlWorkSheet.UsedRange;
        cell1 = range1.Cells[s + 1, j + 1];
        border1 = cell1.Borders;

        if (((IList)terms).Contains(xlWorkSheet.Cells[1, j + 1].Value.ToString()))
        {
            cell1.Interior.Color = System.Drawing.Color.Red;
        }

        range1.Columns.AutoFit();
        range1.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;

        border1.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous;
        border1.Weight = 2d;

    }
}

```

It's sometimes taking like more than 1 minute to load the whole thing. Is there is away to optimize it?.