Whatever message this page gives is out now! Go check it out!

spreadsheetRemoveSheetNumber

Last update:
May 18, 2026

Description

Removes a sheet from a spreadsheet workbook based on its specified number.

Returns

None

History

  • ColdFusion (2025 release): Added the function.

Syntax

spreadsheetRemoveSheetNumber(spreadSheetObject,sheetNumber)

Parameters

Name
Required
Type
Description
spreadSheetObject
Yes
ExcelInfo
The Excel spreadsheet object from which a sheet must be removed.
sheetNumber
Yes
Integer
The sheet number of the sheet that must be removed.

Example

<cfquery name="art" datasource="cfartgallery">
    SELECT * FROM ART
</cfquery>
<cfscript>
    theFile=GetDirectoryFromPath(GetCurrentTemplatePath()) & "art-col.xls";
    // create a spreadsheet object
    theSheet=spreadsheetNew("SampleData")
    // add rows from the table to the spreadsheet
    spreadsheetAddRows(theSheet,art)
    // add sheets
    spreadSheetCreateSheet(theSheet, "Second Sheet")
    spreadSheetCreateSheet(theSheet, "Third Sheet")
    
    // remove sheet number 2
    try{
        spreadsheetRemoveSheetNumber(theSheet,2)
        writeOutput("Sheet removed successfully")
    }
    catch(any e){
        writeOutput(e.message)
    }
    // write the spreadsheet
    spreadsheetWrite(theSheet,theFile,"yes")
</cfscript>

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page