Table of Contents | ||||
---|---|---|---|---|
|
Introduction
Note |
---|
This is Part 2 of the two-part tutorial series Extended Sales Summary scenario. It is recommended that you complete Part 1 - Creating a Dynamic Template before starting this section. |
...
Code Block |
---|
protected void AddCoverSheet() { Worksheet ws = wb.Worksheets.CreateWorksheet("Summary", 0); ws.Select(); ws.ShowGridlines = false; /*******Inserting the Image********/ ws.GetRowProperties(0).Height = 90; string imagePath = RBImage.SelectedItem.Value; Anchor anc = wb.Worksheets[0].CreateAnchor(0, 0, 0, 0); Picture logo = ws.Pictures.CreatePicture(Page.MapPath(@imagePath), anc); /*******Writing values*************/ ws.Cells["A3"].Value = "Date Executed :"; ws.Cells["A4"].Value = "Report For :"; ws.Cells["A6"].Value = "Table of Contents"; ws.Cells["C3"].Value = "%%=WebFormData.Date"; ws.Cells["C4"].Value = "%%=WebFormData.Name"; for (int i = 2; i < wb.Worksheets.Count; i++) { string sheetName = wb.Worksheets[i].Name.ToString(); ws.Cells[7 + i, 1].Formula = "=HYPERLINK(\"#" + sheetName + "!A1\", \"" + sheetName + "\")"; } /******Adding Styles to Text*******/ GlobalStyle labels = wb.CreateStyle(); labels.Font.Bold = true; labels.Font.Size = 12; ws.Cells["A3"].ApplyStyle(labels); ws.Cells["A4"].ApplyStyle(labels); ws.Cells["A6"].ApplyStyle(labels); ws.Cells["A6"].Style.Font.Underline = Font.UnderlineStyle.Single; } |
>>REVIEW HERE
Binding the coversheet data with ExcelTemplate
...