spreadsheet_generate
Generate Excel or CSV spreadsheets from structured data arrays with customizable sheets, headers, and filenames for reporting and data organization.
Instructions
Generate an Excel or CSV spreadsheet ($0.003)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| format | No | xlsx | |
| filename | No | report | |
| sheets | Yes | Array of {name, headers, rows} |
Implementation Reference
- index.js:43-43 (registration)The tool 'spreadsheet_generate' is defined in the TOOLS array, specifying its input schema, endpoint, and price.
{ name: 'spreadsheet_generate', description: 'Generate an Excel or CSV spreadsheet', inputSchema: { type: 'object', properties: { format: { type: 'string', enum: ['xlsx', 'csv'], default: 'xlsx' }, filename: { type: 'string', default: 'report' }, sheets: { type: 'array', description: 'Array of {name, headers, rows}', items: { type: 'object' } } }, required: ['sheets'] }, endpoint: '/spreadsheet/generate', price: '$0.003' }, - index.js:50-79 (handler)The `callTool` function serves as the generic handler that executes the API call for any tool, including 'spreadsheet_generate', based on its endpoint.
async function callTool(endpoint, params) { const fetch = (await import('node-fetch')).default; const isGet = ['GET'].includes((TOOLS.find(t => t.endpoint === endpoint) || {}).method); const url = isGet ? `${BASE_URL}${endpoint}?${new URLSearchParams(params)}` : `${BASE_URL}${endpoint}`; const res = await fetch(url, { method: isGet ? 'GET' : 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${API_KEY}`, }, body: isGet ? undefined : JSON.stringify(params), }); const text = await res.text(); let data; try { data = JSON.parse(text); } catch { data = { raw: text }; } if (!res.ok) { if (res.status === 402) { throw new Error(`Insufficient credits. Add credits at https://iteratools.com. Cost: ${TOOLS.find(t=>t.endpoint===endpoint)?.price || 'see docs'}`); } throw new Error(`API error ${res.status}: ${text.substring(0, 200)}`); } return data; }