Skip to main content

Close Excel

Closes an opened excel file

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

if ContinueOnError property is true, no error is caught when the project is executed even if Catch node is used.

Input

  • Excel File Descriptor - The ID of the excel file descriptor which we want to close. This ID is generated by the Open Excel or the Create Excel node.

How It Works

  1. Validates Input: Checks that the file descriptor is provided and not empty
  2. Verifies Handle: Confirms that the file descriptor exists and corresponds to an open Excel file
  3. Closes File: Releases the Excel file handle and frees associated system resources
  4. Cleanup: Removes the file descriptor from the internal handle registry

Requirements

  • The Excel file must have been previously opened with Open Excel or created with Create Excel
  • A valid file descriptor must be provided
  • Any unsaved changes should be saved using Save Excel before closing

Error Handling

Error CodeDescriptionSolution
Core.Excel.Close.ErrOnCreateConfiguration parsing failedCheck node configuration is valid
Core.Excel.Close.ErrOnMessageMessage parsing failedVerify input message format
Core.Excel.Close.ErrFileDescriptorFile descriptor is empty or does not existEnsure file was opened/created and descriptor is valid

Usage Examples

Example 1: Basic Open-Close Pattern

Standard workflow for reading Excel data:

- Open Excel (data.xlsx) -> fileDescriptor
- Get Range (fileDescriptor, "A1:C10") -> data
- Close Excel (fileDescriptor)

Example 2: Create-Modify-Save-Close Pattern

Complete workflow for creating and populating a new file:

- Create Excel -> newFile
- Create Sheet (newFile, "Report")
- Set Range (newFile, "A1:C1", ["Name", "Email", "Status"])
- Set Range (newFile, "A2:C2", ["John", "john@example.com", "Active"])
- Save Excel (newFile, "output.xlsx")
- Close Excel (newFile)

Example 3: Multiple Files Management

Working with several files simultaneously:

- Open Excel (input1.xlsx) -> file1
- Open Excel (input2.xlsx) -> file2
- Create Excel -> output
- Get Range (file1, "A1:Z100") -> data1
- Get Range (file2, "A1:Z100") -> data2
- Set Range (output, "A1:Z100", {{data1}})
- Set Range (output, "A101:Z200", {{data2}})
- Save Excel (output, "merged.xlsx")
- Close Excel (file1)
- Close Excel (file2)
- Close Excel (output)

Usage Notes

  • Always close Excel files when you're done to free system resources
  • Closing a file without saving will discard all changes made since the last save
  • You cannot perform operations on a file after it has been closed
  • If you try to close an already closed file, you'll receive an error
  • The Close Excel node does not save changes automatically - use Save Excel first
  • File descriptors become invalid after closing and cannot be reused

Tips

  • Follow the pattern: Open/Create -> Modify -> Save -> Close for every Excel workflow
  • Close files as soon as you're done with them to prevent resource leaks
  • In long-running automations, close files between processing batches
  • Use error handling (try-catch) to ensure files are closed even if errors occur
  • Consider using a Finally block to guarantee files are closed
  • Don't reuse file descriptors after closing - open/create a new file instead