Create spreadsheets & documents with LlamaIndex
Give a LlamaIndex agent the ability to emit real spreadsheets by wrapping the OpenOfficeAI API in a FunctionTool. Your agent or query engine can then turn retrieved data into a shareable, editable sheet and return the link — far more useful than printing a table into the response.
import requests
from llama_index.core.tools import FunctionTool
def create_spreadsheet(title: str, rows: list) -> str:
"""Create a shareable spreadsheet (first row = header). Returns a URL."""
r = requests.post(
"https://openofficeai.com/api/v1/sheets",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"title": title, "sheets": [{"rows": rows}]},
)
return r.json()["url"]
tool = FunctionTool.from_defaults(fn=create_spreadsheet)
# agent = FunctionAgent(tools=[tool], llm=llm)How to create a spreadsheet with LlamaIndex
- 1Write a create_spreadsheet function that posts to /api/v1/sheets and returns the url.
- 2Wrap it with FunctionTool.from_defaults(fn=...).
- 3Pass the tool to your agent (FunctionAgent / ReActAgent).
- 4The agent can now turn query results into a shareable spreadsheet link.
Why use OpenOfficeAI with LlamaIndex
- FunctionTool wraps a plain function — no boilerplate.
- Great for "summarize these docs into a sheet" RAG workflows.
- Combine with retrieval so the agent exports what it found.
Frequently asked questions
Does the function docstring matter?
Yes. FunctionTool uses the function signature and docstring to build the tool schema the LLM sees, so a clear docstring describing title and the rows format improves call reliability.
Can I use this in a query engine, not just an agent?
Yes. You can call create_spreadsheet directly in a custom query-engine step after retrieval/synthesis, or expose it as a tool to an agent that decides when exporting is appropriate.
How do I export the result as a file?
After creating the sheet, request /api/v1/download/{id}?format=xlsx or pdf to get the file bytes, which you can save or return alongside the link.
Start creating documents with LlamaIndex
Free tier includes 500 API calls per month — no card required.