using (var package = new ExcelPackage())
{
var workbook = package.Workbook;
//*** Sheet 1
var worksheet = workbook.Worksheets.Add("Sheet1");
//*** Background
using (ExcelRange range = worksheet.Cells["A1:C1"])
{
range.Style.Font.Bold = true;
range.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid; //Set Pattern for the background to Solid
range.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.FromArgb(79, 129, 189)); //Set color to dark blue
range.Style.Font.Color.SetColor(System.Drawing.Color.White);
range.Value = "Text";
}
//*** Merge Cell
using (ExcelRange range = worksheet.Cells["B2:C5"])
{
range.Merge = true;
range.Style.Border.BorderAround(OfficeOpenXml.Style.ExcelBorderStyle.Medium, System.Drawing.Color.Blue);
range.Value = "Text 2";
}
package.SaveAs(new FileInfo(Server.MapPath(@"Xls/myExcel.xlsx")));
}