Skip to content

Excel Close (Session)

Type: excel-close  ·  Package: Excel Activities v1.0.6  ·  Output: —

Saves and closes an Excel session opened with Excel Open. It is Excel Open’s required partner in session mode: it writes the changes to disk and releases the workbook from memory.

It saves the session’s pending changes to the path it was opened with (unless you set save = false) and closes it. Once closed, the session can no longer be used: a later Excel Save on it saves nothing.

  • Closing the same session twice does not fail: the second time does nothing.
  • Inside the body of an Excel Open you can omit session: it closes the body’s workbook.
  • If you saved a copy with savePath in Excel Save, Excel Close still saves to the original path.
ParameterTypeDefaultDescription
sessionZoanExcelSession—The session returned by Excel Open.
ParameterTypeDefaultDescription
savebooltrueSave changes before closing. Set it to false to discard unsaved changes.

This activity does not return a value.

MessageCause and fix
'session' must be a valid Excel session (use excel-open).session is empty or is not an Excel session (for example, a path). Pass the output variable of Excel Open.
The process cannot access the file '…' because it is being used by another process.The file is open in Excel or another program when saving. Close it and retry.
Workbooks need at least one worksheet.The session started from a file that did not exist and no sheet was written. Write something first or close with save = false.
Excel Open path = asset("report.xlsx") → output: workbook
Write Excel Cell session = workbook cell = "A1" value = "Processed"
Excel Close session = workbook

Discard the changes (for example, after a failed validation):

Excel Close session = workbook save = false