Skip to main content

Delete worksheet from Excel file using n8n action

PDF4me Delete Worksheets from Excel removes one or more worksheets from Excel workbooks through n8n automation workflows. Process Excel files via n8n triggers, binary data, base64 strings, or public URLs to delete worksheets by name or index with automatic validation ensuring at least one worksheet always remains (Excel requirement). This solution is ideal for template cleanup, removing temporary sheets, automated workbook maintenance, and document preparation workflows that require worksheet removal with safety checks and seamless integration.

Setup

Add the PDF4me "Delete Worksheets" node to your n8n workflow and configure the required parameters. For initial setup instructions, see our n8n Integration Guide.

Prerequisites:

  • PDF4me API credentials
  • n8n workflow access

Configuration:

  1. Add PDF4me node to workflow
  2. Select "Delete worksheet from Excel file" action
  3. Configure input parameters (see below)
Delete Worksheets from Excel

Parameters

Complete list of parameters for the Delete Worksheets action. Configure these parameters to control worksheet deletion.

Important: Parameters marked with an asterisk (***) are required. At least one worksheet must remain after deletion (Excel requirement). Worksheet indexes use 0-based numbering.

ParameterTypeDescriptionExample
Input Data Type***StringExcel Input Format Selection
• Choose the format of your Excel data input
• PDF4me supports multiple input types
• Options: Binary Data, Base64 String, or URL
Binary Data
Input Binary Field***BinaryBinary Excel File Input (Required if Binary Data)
• Reference Excel file (.xlsx, .xls) from previous n8n node or file upload
• PDF4me processes binary Excel files with automatic format detection
• Required when Input Data Type is "Binary Data"
{{ $binary.data }}
Base64 Excel Content***StringBase64 Encoded Excel Input (Required if Base64 String)
• Provide Excel content (.xlsx, .xls) as base64 encoded string
• PDF4me automatically decodes and processes the Excel content
• Required when Input Data Type is "Base64 String"
UEsDBBQABgAI...
Excel URL***StringPublic Excel URL Input (Required if URL)
• Provide a public/open permission URL to the Excel file (.xlsx, .xls)
• PDF4me downloads and processes the Excel file from the provided URL
• Required when Input Data Type is "URL"
https://abc.com/data.xlsx
Excel Name***StringExcel Input Filename
• Specify the name of the input Excel file with proper extension (.xlsx, .xls)
• PDF4me uses this for format detection and processing optimization
data.xlsx
Worksheet NamesStringComma-Separated Worksheet Names
• List of worksheet names to delete
• Format: "Sheet1,Temp,Old"
Selection Logic: If provided → Delete those named worksheets. If both parameters provided → Delete worksheets matching EITHER (union). Duplicates handled - same worksheet deleted only once
• Case-sensitive worksheet names
Temp,Draft,Old
Worksheet IndexesStringComma-Separated Indexes (0-based)
• List of worksheet indexes to delete
• Format: "0,2,5" (Index 0 = first sheet, Index 1 = second sheet, etc.)
Selection Logic: If provided → Delete those indexed worksheets. Valid range: 0 to (Total Worksheets - 1)
0-based indexing: Index 0 = first worksheet
Critical Rule: At least 1 worksheet must remain after deletion (Excel requirement)
0,2
Binary Data Output Name***StringBinary Data Output Mapping
• Define the variable name for accessing generated Excel binary data
• Used in subsequent workflow actions
• Essential for workflow automation
document

Output

Output Parameters

ParameterTypeDescriptionExample
fileNameStringExcel document filename with worksheets deleted - The name of the output Excel document file after worksheet deletionexcel_worksheet_deleted.xlsx
fileSizeNumberFile size in bytes - The size of the Excel document in bytes after worksheet deletion171937
successBooleanPDF4me operation status - Boolean flag indicating the success or failure of the worksheet deletion process. PDF4me returns true for successful deletions and false for any errorstrue
originalFileNameStringOriginal Excel document filename - The name of the input Excel document filemyExcelFile.xlsx
deleteByStringDeletion method - The method used to identify worksheets for deletion. Values: "name" if deleted by worksheet names, "index" if deleted by worksheet indexesname
worksheetNamesStringWorksheet names deleted - Comma-separated list of worksheet names that were deletedSheet2
messageStringOperation message - Descriptive message indicating the result of the worksheet deletion operation, including the worksheet names and deletion methodSuccessfully deleted worksheet(s) 'Sheet2' by name

N8N Action Response

The PDF4me Delete worksheet from Excel file API returns a response that can be viewed in multiple formats. Choose the view that best fits your needs:

JSON Response Format

The raw JSON response from the API:

[
{
"fileName": "excel_worksheet_deleted.xlsx",
"fileSize": 171937,
"success": true,
"originalFileName": "myExcelFile.xlsx",
"deleteBy": "name",
"worksheetNames": "Sheet2",
"message": "Successfully deleted worksheet(s) 'Sheet2' by name"
}
]

Use Cases

Template Cleanup and Maintenance

  • Remove temporary or sample worksheets from Excel templates before distribution
  • Clean up old or unused worksheets from workbooks to reduce file size
  • Prepare templates for new use by removing example data sheets

Document Preparation and Standardization

  • Remove internal review worksheets before client delivery
  • Delete backup or archive sheets from production workbooks
  • Standardize workbook structure by removing unnecessary worksheets

Automated Workbook Management

  • Remove worksheets based on date or status criteria in automated workflows
  • Clean up worksheets after data migration or consolidation operations
  • Maintain workbook organization by removing duplicate or redundant sheets

Get Help