EasyXLS™ library allows you to delete sheets from a workbook. The sheet to be deleted can be identified by name or by index. The sheet can be a worksheet or a chart sheet.
// Create an instance of the class that exports Excel files, having five sheets
ExcelDocument workbook = new ExcelDocument(5);
...
// Delete sheet
workbook.easy_removeSheet("Sheet2");
' Create an instance of the class that exports Excel files, having five sheets
ExcelDocument workbook = new ExcelDocument(5)
...
' Delete sheet
workbook.easy_removeSheet("Sheet2")
C++// Create an instance of the class that exports Excel files, having five sheets
EasyXLS::IExcelDocumentPtr workbook;
hr = CoCreateInstance(__uuidof(EasyXLS::ExcelDocument),
NULL,
CLSCTX_ALL,
__uuidof(EasyXLS::IExcelDocument),
(void**) &workbook) ;
workbook->easy_addWorksheet_2("Sheet1");
workbook->easy_addWorksheet_2("Sheet2");
workbook->easy_addWorksheet_2("Sheet3");
workbook->easy_addWorksheet_2("Sheet4");
workbook->easy_addWorksheet_2("Sheet5");
...
// Delete sheet
workbook->easy_removeSheet_2("Sheet2");
C++.NET// Create an instance of the class that exports Excel files, having five sheets
ExcelDocument ^workbook = gcnew ExcelDocument(5);
...
// Delete sheet
workbook->easy_removeSheet("Sheet2");
// Create an instance of the class that exports Excel files, having five sheets
ExcelDocument workbook = new ExcelDocument(5);
...
// Delete sheet
workbook.easy_removeSheet("Sheet2");
.NET:// Create an instance of the class that exports Excel files, having five sheets
$workbook = new COM("EasyXLS.ExcelDocument");
$workbook->easy_addWorksheet_2("Sheet1");
$workbook->easy_addWorksheet_2("Sheet2");
$workbook->easy_addWorksheet_2("Sheet3");
$workbook->easy_addWorksheet_2("Sheet4");
$workbook->easy_addWorksheet_2("Sheet5");
...
// Delete sheet
$workbook->easy_removeSheet_2("Sheet2");
Java:// Create an instance of the class that exports Excel files, having five sheets
$workbook = new java("EasyXLS.ExcelDocument");
$workbook->easy_addWorksheet("Sheet1");
$workbook->easy_addWorksheet("Sheet2");
$workbook->easy_addWorksheet("Sheet3");
$workbook->easy_addWorksheet("Sheet4");
$workbook->easy_addWorksheet("Sheet5");
...
// Delete sheet
$workbook->easy_removeSheet("Sheet2");
' Create an instance of the class that exports Excel files, having five sheetsset workbook = Server.CreateObject("EasyXLS.ExcelDocument")
workbook.easy_addWorksheet_2("Sheet1")
workbook.easy_addWorksheet_2("Sheet2")
workbook.easy_addWorksheet_2("Sheet3")
workbook.easy_addWorksheet_2("Sheet4")
workbook.easy_addWorksheet_2("Sheet5")
...
' Delete sheet
workbook.easy_removeSheet_2("Sheet2")
' Create an instance of the class that exports Excel files, having five sheetsSet workbook = CreateObject("EasyXLS.ExcelDocument")
workbook.easy_addWorksheet_2 ("Sheet1")
workbook.easy_addWorksheet_2 ("Sheet2")
workbook.easy_addWorksheet_2 ("Sheet3")
workbook.easy_addWorksheet_2 ("Sheet4")
workbook.easy_addWorksheet_2 ("Sheet5")
...
' Delete sheet
workbook.easy_removeSheet_2 ("Sheet2")
' Create an instance of the class that exports Excel files, having five sheetsSet workbook = CreateObject("EasyXLS.ExcelDocument")
workbook.easy_addWorksheet_2("Sheet1")
workbook.easy_addWorksheet_2("Sheet2")
workbook.easy_addWorksheet_2("Sheet3")
workbook.easy_addWorksheet_2("Sheet4")
workbook.easy_addWorksheet_2("Sheet5")
...
' Delete sheet
workbook.easy_removeSheet_2("Sheet2")
<!-- Create an instance of the class that exports Excel files, having five sheets --><cfobject type="java"class="EasyXLS.ExcelDocument"name="workbook"action="CREATE"><cfset ret = workbook.easy_addWorksheet("Sheet1")><cfset ret = workbook.easy_addWorksheet("Sheet2")><cfset ret = workbook.easy_addWorksheet("Sheet3")><cfset ret = workbook.easy_addWorksheet("Sheet4")><cfset ret = workbook.easy_addWorksheet("Sheet5")>
...
<!-- Delete sheet --><cfset ret = workbook.easy_removeSheet("Sheet2")>
.NET:# Create an instance of the class that exports Excel files, having five sheets
workbook = ExcelDocument(5)
...
#Delete sheet
workbook.easy_removeSheet("Sheet2")
Java:# Create an instance of the class that exports Excel files, having five sheets
workbook = gateway.jvm.ExcelDocument(5)
...
#Delete sheet
workbook.easy_removeSheet("Sheet2")
Remove sheet by index
The below example shows how to delete a sheet from an Excel file using the index of the sheet into the workbook.
// Create an instance of the class that exports Excel files, having five sheets
ExcelDocument workbook = new ExcelDocument(5);
...
// Delete sheet
workbook.easy_removeSheet(1);
' Create an instance of the class that exports Excel files, having five sheets
ExcelDocument workbook = new ExcelDocument(5)
...
' Delete sheet
workbook.easy_removeSheet(1)
C++// Create an instance of the class that exports Excel files, having five sheets
EasyXLS::IExcelDocumentPtr workbook;
hr = CoCreateInstance(__uuidof(EasyXLS::ExcelDocument),
NULL,
CLSCTX_ALL,
__uuidof(EasyXLS::IExcelDocument),
(void**) &workbook) ;
workbook->easy_addWorksheet_2("Sheet1");
workbook->easy_addWorksheet_2("Sheet2");
workbook->easy_addWorksheet_2("Sheet3");
workbook->easy_addWorksheet_2("Sheet4");
workbook->easy_addWorksheet_2("Sheet5");
...
// Delete sheet
workbook->easy_removeSheet(1);
C++.NET// Create an instance of the class that exports Excel files, having five sheets
ExcelDocument ^workbook = gcnew ExcelDocument(5);
...
// Delete sheet
workbook->easy_removeSheet(1);
// Create an instance of the class that exports Excel files, having five sheets
ExcelDocument workbook = new ExcelDocument(5);
...
// Delete sheet
workbook.easy_removeSheet(1);
.NET:// Create an instance of the class that exports Excel files, having five sheets
$workbook = new COM("EasyXLS.ExcelDocument");
$workbook->easy_addWorksheet_2("Sheet1");
$workbook->easy_addWorksheet_2("Sheet2");
$workbook->easy_addWorksheet_2("Sheet3");
$workbook->easy_addWorksheet_2("Sheet4");
$workbook->easy_addWorksheet_2("Sheet5");
...
// Delete sheet
$workbook->easy_removeSheet(1);
Java:// Create an instance of the class that exports Excel files, having five sheets
$workbook = new java("EasyXLS.ExcelDocument");
$workbook->easy_addWorksheet("Sheet1");
$workbook->easy_addWorksheet("Sheet2");
$workbook->easy_addWorksheet("Sheet3");
$workbook->easy_addWorksheet("Sheet4");
$workbook->easy_addWorksheet("Sheet5");
...
// Delete sheet
$workbook->easy_removeSheet(1);
' Create an instance of the class that exports Excel files, having five sheetsset workbook = Server.CreateObject("EasyXLS.ExcelDocument")
workbook.easy_addWorksheet_2("Sheet1")
workbook.easy_addWorksheet_2("Sheet2")
workbook.easy_addWorksheet_2("Sheet3")
workbook.easy_addWorksheet_2("Sheet4")
workbook.easy_addWorksheet_2("Sheet5")
...
' Delete sheet
workbook.easy_removeSheet(1)
' Create an instance of the class that exports Excel files, having five sheetsSet workbook = CreateObject("EasyXLS.ExcelDocument")
workbook.easy_addWorksheet_2 ("Sheet1")
workbook.easy_addWorksheet_2 ("Sheet2")
workbook.easy_addWorksheet_2 ("Sheet3")
workbook.easy_addWorksheet_2 ("Sheet4")
workbook.easy_addWorksheet_2 ("Sheet5")
...
' Delete sheet
workbook.easy_removeSheet (1)
' Create an instance of the class that exports Excel files, having five sheetsSet workbook = CreateObject("EasyXLS.ExcelDocument")
workbook.easy_addWorksheet_2("Sheet1")
workbook.easy_addWorksheet_2("Sheet2")
workbook.easy_addWorksheet_2("Sheet3")
workbook.easy_addWorksheet_2("Sheet4")
workbook.easy_addWorksheet_2("Sheet5")
...
' Delete sheet
workbook.easy_removeSheet(1)
<!-- Create an instance of the class that exports Excel files, having five sheets --><cfobject type="java"class="EasyXLS.ExcelDocument"name="workbook"action="CREATE"><cfset ret = workbook.easy_addWorksheet("Sheet1")><cfset ret = workbook.easy_addWorksheet("Sheet2")><cfset ret = workbook.easy_addWorksheet("Sheet3")><cfset ret = workbook.easy_addWorksheet("Sheet4")><cfset ret = workbook.easy_addWorksheet("Sheet5")>
...
<!-- Delete sheet --><cfset ret = workbook.easy_removeSheet(JavaCast("int", "1"))>
.NET:# Create an instance of the class that exports Excel files, having five sheets
workbook = ExcelDocument(5)
...
#Delete sheet
workbook.easy_removeSheet(1)
Java:# Create an instance of the class that exports Excel files, having five sheets
workbook = gateway.jvm.ExcelDocument(5)
...
#Delete sheet
workbook.easy_removeSheet(1)