Excel to PDF
Excel to PDF
Section titled “Excel to PDF”Type: excel-to-pdf · Package: Excel Activities v1.0.6 · Output: string
Converts an Excel workbook to PDF: a report you are about to email, an account statement to archive, a quote for a customer. It accepts .xlsx, .xlsm, .xls, .csv and .ods — including formats the rest of the package does not read — and returns the path of the generated PDF.
How it works
Section titled “How it works”- It takes the workbook at
pathand decides where to save the PDF: atoutputPathor, if you leave it empty, in the same folder and with the same name as the workbook, with a.pdfextension. Relative paths are resolved from the robot’s working folder. - It converts with the engine set in
engine:auto(the default): tries LibreOffice first and, if it is missing or fails, Microsoft Excel.libreoffice: LibreOffice only.excel: Microsoft Excel only (Windows only). Excel runs hidden and closes without saving changes to the workbook.
- It returns the full path of the PDF.
The PDF contains the whole workbook, with the page setup saved in the file (print area, orientation, margins). If a PDF already exists at the destination path, it is overwritten. Missing folders are created. The conversion has no time limit of its own: it waits for the engine to finish (and is interrupted if the run is stopped).
LibreOffice runs with its own temporary profile, so the conversion works even if you have LibreOffice open.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
path | string | — | Path of the workbook to convert (.xlsx, .xlsm, .xls, .csv, .ods). It must exist. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
outputPath | string | — | Destination .pdf path. If omitted, the workbook’s folder and name with a .pdf extension. |
engine | string | "auto" | Conversion engine: auto · libreoffice · excel. auto tries LibreOffice, then Microsoft Excel. An unrecognized value is treated as auto. |
Output
Section titled “Output”Returns a string with the full (absolute) path of the generated PDF, e.g. C:\reports\pdf\sales-september.pdf.
Common errors
Section titled “Common errors”When no engine manages to convert, the activity fails with a single message that gathers the reason for each attempt, separated by |:
| Message | Cause and fix |
|---|---|
'path' is required. | path is empty. |
File not found. | The path does not exist on the machine where the robot runs. |
Could not convert the workbook to PDF. LibreOffice: 'soffice' not found (install LibreOffice or set ZOAN_SOFFICE_PATH). | LibreOffice is not installed (or not where it is looked for). Install it or set ZOAN_SOFFICE_PATH. |
… Excel: Microsoft Excel is not installed. | The conversion was attempted with Excel and it is not installed. |
… Excel: COM automation requires Windows. | The excel engine only works on Windows. On other systems, use LibreOffice. |
… LibreOffice: LibreOffice could not convert the document (exit …). | LibreOffice could not open or convert the file (corrupted, password-protected…). The message includes the details LibreOffice returned. |
For conversions that depend on the machine’s resources, wrap the activity in a Try / Catch and log the message: it says exactly which engine failed and why.
Example
Section titled “Example”Fill in a template, convert it to PDF and send it:
Copy File source = asset("quote_template.xlsx") destination = "C:/quotes/Q-0815.xlsx" overwrite = trueWrite Excel Cell path = "C:/quotes/Q-0815.xlsx" sheet = "Quote" cell = "B4" value = customerExcel to PDF path = "C:/quotes/Q-0815.xlsx" → output: pdfPathGmail — Send to = "purchasing@example.com" subject = "Quote Q-0815" attachments = pdfPathSave the PDF to another folder:
Excel to PDF path = reportPath outputPath = "C:/reports/pdf/sales-september.pdf" → output: pdfPathRelated activities
Section titled “Related activities”- Excel Save / Excel Close — save changes before converting.
- Word to PDF — the same for Word documents.
- PDF — work with the generated PDF.