i manteined legacy code like yours and it may brings you to headache with browser compatibility...
i suggest you using epplus (free) download it with nuget.
https://www.nuget.org/packages/EPPlus/[
^]
https://epplus.codeplex.com/wikipage?title=FAQ[
^]
you can format cells like you want using code like
worksheet.Cells["A1:B3,D1:E57"].Style.NumberFormat.Format = "#,##0";
worksheet.Cells["A:B"].Style.Font.Bold = true;
worksheet.Cells["1:1,A:A,C3"].Style.Font.Bold = true;
worksheet.Cells["A:XFD"].Style.Font.Name = "Arial";
worksheet.Cells.Style.Fill.PatternType = ExcelFillStyle.Solid;
worksheet.Cells.Style.Fill.BackgroundColor.SetColor(Color.LightGreen);