Answers
Short answer: On Windows you have three real command-line routes. LibreOffice in headless mode is free and needs no Excel, but renders with its own engine. A paid CLI converter such as Total Excel Converter batches without Excel and is built for servers. Or you script Excel itself through COM from PowerShell, which gives Excel’s exact output because it is Excel. All three render your page setup as-is, so whatever the sheet does wrong on paper today it will do wrong on schedule tomorrow.
soffice --headless --convert-to pdf --outdir C:\out C:\in\*.xlsx
Free, scriptable, no Microsoft licence, and it will happily run over a folder. The trade is fidelity: LibreOffice reads the workbook with its own engine, so fonts, conditional formatting and pivot layouts can shift compared with what Excel shows. Close the LibreOffice window first — a running instance makes the headless call fail quietly.
Tools like Total Excel Converter run from the command line, batch a folder, and need no Excel installed, which is the deciding factor on a server or a build agent. They render with their own parser, so the same fidelity caveat applies. See the full comparison.
$excel = New-Object -ComObject Excel.Application
$excel.Visible = $false
$excel.DisplayAlerts = $false
foreach ($f in Get-ChildItem 'C:\in\*.xlsx') {
$wb = $excel.Workbooks.Open($f.FullName)
$out = Join-Path 'C:\out' ($f.BaseName + '.pdf')
$wb.ExportAsFixedFormat(0, $out)
$wb.Close($false)
}
$excel.Quit()
This produces exactly what File → Save as PDF produces, because it calls the same exporter. Two warnings from everyone who has run it in production: Excel must be installed and licensed on that machine, and COM automation under a service account or Task Scheduler is genuinely fragile — a modal dialog with nobody to click it hangs the job. Release the COM object when you are done, or you will collect orphaned Excel processes.
OfficeToPDF is the maintained version of this idea: a free command-line wrapper around Office’s own export, so you get the same output without writing the script.
None of them changes the layout. A row that splits across a page break splits in every one of these outputs; a table wider than the paper is pushed onto a separate strip of pages in every one of them. Automation makes a result repeatable, which is worth having only once the result is right.
CrazySmartPDF has no public command-line interface — if a scheduled unattended job is a hard requirement, one of the three routes above is your answer, and that is the honest recommendation. What it offers instead is a desktop folder batch with a run log, a layout pass that keeps rows whole and wide tables readable, and a per-file flag on pages that came out blank or clipped. A person starts the run. Windows with Excel 2016+, free on your own files. See how it works.
Can I convert Excel to PDF from the command line without Excel installed? Yes — LibreOffice headless or a CLI converter with its own parser. Both render the workbook with their own engine rather than Excel’s, which is the trade you are accepting.
Why does my PowerShell COM script hang under Task Scheduler? Excel automation expects an interactive desktop session. Under a service account a modal prompt has nobody to dismiss it, and the job waits. Run it as a logged-in user, or use a converter that does not need Office.
Does converting from the command line change the layout? No. Every route here renders the page setup the workbook already has, so the same splits and clipping appear in the automated output.
Does CrazySmartPDF have a command-line interface? No. The shipped batch route is the Windows desktop app, which takes a folder in one pass and writes a run log, started by a person.