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.
Click anywhere in the table. On the Home tab on the ribbon, click the down arrow next to Table and select Toggle Header Row.
Go to the "Insert" tab on the Excel toolbar, and then click the “Header & Footer” button in the Text group to start the process of adding a header. Excel changes the document view to a Page Layout view. Click on the top of your document where it says “Click to Add Header,” and then type the header for your document.
The row heading or row header is the gray-colored column located to the left of column 1 in the worksheet containing the numbers (1, 2, 3, etc.) used to identify each row in the worksheet.
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";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With