Create Workbook with One Worksheet

How might I efficiently remove the unused second and third worksheets from a new Workbook? These seem created each time I add a Workbook using: Dim ReportWorkbook As Workbook = New WorkbookManager().Workbooks.Add(ExcelVersion.Excel2013) Alternatively, how might I specify I want just one worksheet when creating the workbook? What I've tried: Using ComponentPro v7.0.226.56 and Microsoft Visual Studio Professional 2017 Web Forms project ( ReportWorkbook.Worksheets(2).Remove() ReportWorkbook.Worksheets(1).Remove() Note: removing last-to-first to avoid index out-of-range errors. I've looked at WorksheetCollection but that doesn't seem to have member functions to remove Worksheet ranges. Thank you
edited 2/1/2019 6:46:52 PM
asked 2/1/2019 4:25:19 PM
add a comment

1 Answers

I think I can answer my own question by using an object initializer: Dim ReportWorkbook As Workbook = (New WorkbookManager() With {.SheetsInNewWorkbook = 1, .StandardFont = "Arial", .StandardFontSize = 12} ).Workbooks.Add(version:=ExcelVersion.Excel2013) Note: this also allows for the added benefit of setting other standard settings, like font name/size, etc. Reference, "How to: Declare an Object by Using an Object Initializer (Visual Basic)": [][1] (accessed 02/01/2019) Thank you [1]:
edited 2/1/2019 5:16:19 PM
answered 2/1/2019 5:11:56 PM
add a comment

Your Answer

Not the answer you're looking for? Browse other questions tagged excel or ask your own question.