Skip to content

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.

  1. It takes the workbook at path and decides where to save the PDF: at outputPath or, if you leave it empty, in the same folder and with the same name as the workbook, with a .pdf extension. Relative paths are resolved from the robot’s working folder.
  2. 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.
  3. 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.

ParameterTypeDefaultDescription
pathstring—Path of the workbook to convert (.xlsx, .xlsm, .xls, .csv, .ods). It must exist.
ParameterTypeDefaultDescription
outputPathstring—Destination .pdf path. If omitted, the workbook’s folder and name with a .pdf extension.
enginestring"auto"Conversion engine: auto · libreoffice · excel. auto tries LibreOffice, then Microsoft Excel. An unrecognized value is treated as auto.

Returns a string with the full (absolute) path of the generated PDF, e.g. C:\reports\pdf\sales-september.pdf.

When no engine manages to convert, the activity fails with a single message that gathers the reason for each attempt, separated by |:

MessageCause 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.

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 = true
Write Excel Cell path = "C:/quotes/Q-0815.xlsx" sheet = "Quote" cell = "B4" value = customer
Excel to PDF path = "C:/quotes/Q-0815.xlsx" → output: pdfPath
Gmail — Send to = "purchasing@example.com" subject = "Quote Q-0815" attachments = pdfPath

Save the PDF to another folder:

Excel to PDF path = reportPath outputPath = "C:/reports/pdf/sales-september.pdf" → output: pdfPath