Create spreadsheets & documents with Haystack
In Haystack, wrap the OpenOfficeAI API as a tool so an Agent or a tool-calling pipeline can produce shareable spreadsheets — for example, exporting retrieved or generated data. Define the function, register it as a Tool, and connect it to your generator.
import requests
from haystack.tools import Tool
def create_spreadsheet(title: str, rows: list) -> str:
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"]
sheet_tool = Tool(
name="create_spreadsheet",
description="Create a shareable spreadsheet and return its URL.",
parameters={"type": "object", "properties": {
"title": {"type": "string"},
"rows": {"type": "array", "items": {"type": "array"}}},
"required": ["title", "rows"]},
function=create_spreadsheet,
)How to create a spreadsheet with Haystack
- 1Write a create_spreadsheet function that calls /api/v1/sheets.
- 2Wrap it in a Haystack Tool with a JSON-schema parameters spec.
- 3Pass the tool to a ToolInvoker or a tool-calling generator/Agent.
- 4The pipeline returns the shareable url when the model invokes it.
Why use OpenOfficeAI with Haystack
- Plugs into RAG pipelines — export what you retrieve.
- Standard Tool abstraction works across generators.
- Turn pipeline output into a shareable artifact.
Frequently asked questions
Where does the tool fit in a pipeline?
Connect it to a tool-calling chat generator via a ToolInvoker component, or give it to a Haystack Agent. The model decides when to call it during the run.
Can I export retrieved documents to a sheet?
Yes. Shape your retrieved data into rows in a custom component (or in the tool itself) before posting, so the spreadsheet reflects what the pipeline found.
Does this work with the Agent component?
Yes. Add the tool to the Agent's tools list and it can call create_spreadsheet as one of its available actions.
Start creating documents with Haystack
Free tier includes 500 API calls per month — no card required.
Related integrations