Guide
Can an AI agent create Word, Excel and PDF files in the cloud?
Yes. An agent can create Word, Excel and PDF files on any Linux machine that has the right libraries, and a Sanbox OpenCode Computer comes with them installed: LibreOffice Writer and Calc, pandoc, python-docx, openpyxl, xlsxwriter, reportlab, pdfplumber and pandas. You copy your input files in, ask the agent for the documents, and copy or download the results. Slides (PowerPoint) aren't included today; a slides-capable office Computer is enabled on request.
Run this with your agent
Read https://sanbox.cloud/kb/teams/agents-that-write-word-excel-and-pdf.md and follow it to have a Sanbox Computer produce Word, Excel and PDF files.
If the Sanbox CLI is missing, install it with `npm install -g @sanlabs/sanbox-cli@latest`
and sign in with `sanbox login`. Show me each command before you create, stop or delete a Computer.
What's installed for documents?
| Format | Tools in the OpenCode Computer |
|---|---|
| Word (.docx) | python-docx, LibreOffice Writer, pandoc |
| Excel (.xlsx) | openpyxl, xlsxwriter, pandas, LibreOffice Calc |
| PDF, create | reportlab, LibreOffice |
| PDF, read and edit | pdfplumber, pypdf, pdfminer.six, poppler-utils, qpdf |
| Charts and images | matplotlib, Pillow |
| Data | pandas, numpy, python3 and pip |
Fonts are installed too, so documents render with real typefaces. The image doesn't include python-pptx or LibreOffice Impress.
1. Create an OpenCode Computer template
sanbox model-providers list --json
sanbox model-providers models <provider-id> --json
sanbox templates create --name "Office work" --type opencode-computer \
--model-provider <provider-id> --model <model-id> --json
sanbox templates validate <template-id> --json
Document work needs no internet access beyond the model, so you can leave out --network-policy. The Computer then stays deny-by-default and still reaches the template's model provider.
2. Start the Computer and copy your files in
sanbox run --template <template-id> --json
sanbox runs get <run-id> --json
sanbox cp ./input <run-id>:/workspace
Wait until runs get shows the run as running before you copy. sanbox cp creates the folder under its own name, so ./input arrives as /workspace/input.
To check the libraries yourself:
sanbox exec <run-id> -- python3 -c "import docx, openpyxl, xlsxwriter, reportlab, pdfplumber; print('ok')"
3. Ask for the documents
Open the Computer in the Sanbox console and give the agent the task in chat. Be specific about inputs, outputs and tools:
Read /workspace/input/sales.csv.
Write /workspace/output/sales.xlsx with one sheet per region and a totals sheet, using openpyxl.
Write /workspace/output/summary.docx with a one-page summary and a bar chart made with matplotlib, using python-docx.
Convert summary.docx to /workspace/output/summary.pdf with LibreOffice in headless mode.
Putting every deliverable under /workspace/output matters: that's the folder Sanbox exports as the run's artifacts. You can also drive the agent from code through the OpenCode SDK with sanbox opencode connect <run-id> --expires 1h.
4. Download the results
While the Computer runs, copy the folder out:
sanbox cp <run-id>:/workspace/output .
This creates ./output on your machine. Or stop the Computer and download its artifacts:
sanbox runs stop <run-id> --wait --json
sanbox runs artifacts <run-id> --json
sanbox runs download <run-id> --output ./results --json
Downloads return each file's path, size and SHA-256 digest. Each file can be up to 256 MiB.
How do I convert Word to PDF?
LibreOffice converts documents from the command line. Its --headless option runs without a user interface, and --convert-to pdf writes the PDF to the current directory, or to the folder given with --outdir. For example, the agent can run:
sanbox exec <run-id> --cwd /workspace/output -- soffice --headless --convert-to pdf summary.docx
Check complex layouts in Microsoft Word or Excel before you send them. LibreOffice and the Python libraries write standard files, but they aren't Microsoft Office.
Slides (PowerPoint): enabled on request
The OpenCode Computer doesn't make slide decks today. A slides-capable office Computer, with tools for PowerPoint files, is enabled per organisation on request: Enable it for your organisation.
Snapshot it
If your team adds its own templates, fonts or helper scripts, set them up once, stop the Computer and snapshot it:
sanbox snapshots create --run <stopped-run-id> --name office-base --wait
sanbox run --snapshot office-base --json
Each run from the snapshot starts with those files already in place.
What this doesn't do
- Slides. No python-pptx and no LibreOffice Impress.
- Microsoft Office. Files are made with open-source tools, so check formatting that depends on Word or Excel.
- Huge files. Artifact downloads are limited to 256 MiB per file, and the disk is 1 to 8 GB.
- Files outside
/workspace/output. Only that folder is exported as artifacts. Usesanbox cpfor anything else.
Related
- How do I give every employee their own AI agent computer?
- How do I run OpenCode as a server on a remote computer?
- How do I run 10 coding-agent tasks in parallel without them clashing?
- What survives when an agent's computer stops?
Sources
- LibreOffice Help, Starting LibreOffice with parameters (
--headless,--convert-to,--outdir), checked 2026-11-06