Add extra header row at top of excel sheet [EPPlus]
asp.net, c#, epplus
Solution
What you want it's merged cells. You can do it like this:
ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Demo");
ws.Cells["A1:G1"].Merge = true;
And keep using EPPlus. It's very good
Other sample with formatting:
using (ExcelRange Title = Cells[1, 1, 1, dt.Columns.Count]) {
Title.Merge = true;
Title.Style.Font.Size = 18;
Title.Style.Font.Bold = true;
Title.Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
Title.Style.Fill.BackgroundColor.SetColor(systemColor);
Title.Style.VerticalAlignment = ExcelVerticalAlignment.Center;
Title.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
Title.Style.TextRotation = 90;
Title.Value = "This is my title";
}
Problem
I am working with a web application. There,i am supposed to export data to excel. For that,i have made use of EPPlus. I searched alot but cant find out a way to add extra row at top of excel sheet. Please have a look at below image to better understand the idea. I tried merging the header,but then i wont get other headers,so i think 'add extra row at top' wil be a better phrase for this. I am not bounded to use EPPlus. If there is other ways available,i will surely approach it. Can any one help me with this? I really appreciate the response.