Excel Save (Session)
Excel Save (Session)
Section titled “Excel Save (Session)”Type: excel-save · Package: Excel Activities v1.0.6 · Output: —
Saves to disk the changes of an Excel session without closing it. Useful for intermediate saves during a long process (so you don’t lose progress), or to save a copy to another path (like “Save As”).
How it works
Section titled “How it works”It writes the session’s changes to the file. If you set savePath, it writes a copy to that path; if you leave it empty, it saves to the original path. Either way, the session stays open.
savePathdoes not change the session’s path: later Excel Save calls withoutsavePathand the final Excel Close save to the original path again.- If a file already exists at the destination, it is overwritten. Missing folders are created.
- The destination extension must be
.xlsx,.xlsm,.xltxor.xltm. - Inside the
bodyof an Excel Open you can omitsession. - On a session that is already closed, it does nothing.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
session | ZoanExcelSession | — | The session returned by Excel Open. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
savePath | string | — | Save a copy to a different path (Save As). Leave empty to save to the original path. |
Output
Section titled “Output”This activity does not return a value.
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
'session' must be a valid Excel session (use excel-open). | session is empty or is not an Excel session. Pass the output variable of Excel Open. |
Extension 'pdf' is not supported. Supported extensions are '.xlsx', '.xlsm', '.xltx' and '.xltm'. | savePath has a non-Excel extension. For a PDF, save and then use Excel to PDF. |
The process cannot access the file '…' because it is being used by another process. | The destination file is open in Excel or another program. Close it and retry. |
Workbooks need at least one worksheet. | The session started from a file that did not exist and has no sheet yet. Write something before saving. |
Example
Section titled “Example”Intermediate save inside a long loop, and a final dated copy:
Excel Open path = asset("accumulated.xlsx") → output: workbookFor Each items = batches itemVariable = batch └─ activities: Append Excel Rows session = workbook data = batch Excel Save session = workbook // intermediate save, just in caseExcel Save session = workbook savePath = "C:/backups/accumulated_" + today().ToString("yyyyMMdd") + ".xlsx"Excel Close session = workbookRelated activities
Section titled “Related activities”- Excel Close — save and close when done.
- Excel Open — open the session.
- Excel to PDF — convert the saved file to PDF.