I am using Infragistics.Documents.Excel to work on Excel,
I want to delete a worksheet programmatically, but i am not finding any method to delete a worksheet.
Please suggest me in this.
You can use the Remove or RemoveAt methods on the Workbook.Worksheets collection.
I am populating the excel with data from various datatables. My spreadsheet will have around 18 worksheets.
The default WorkSheet1 is the last worksheet. My client don't want to see the default worksheet.
I could not find a way to delete the default WorkSheet1. Below is the code which throws an error - Key not found.
Worksheet workSheet1 = workbook.Worksheets["WorkSheet1"];
Can someone help me with this?
Okay this might be way too late but for any other person seeking this solution.
use Workbook.Worksheets.RemoveAt(index of sheet to remove);
so for the default Worksheet