Add an extra title bar over the excel sheet [EPPlus]

I am working with a web application. There I have to export the data to excel. For this, I used EPPlus.

I searched a lot, but couldn't find a way to add an extra row on top of the excel sheet. Please see the image below to better understand the idea.

enter image description here

I tried to merge the header, but then I won’t get any other headers, so I think add an extra line at the top to be the best phrase for this.

I can not use EPPlus. If there are other ways available, I will definitely go for it.

Can someone help me with this? I really appreciate the answer.

+6
source share
1 answer

What do you want to merge cells. You can do it as follows:

ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Demo"); ws.Cells["A1:G1"].Merge = true; 

And keep using EPPlus. It is very good

Another formatting pattern:

 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"; } 
+6
source

Source: https://habr.com/ru/post/950904/


All Articles