Skip to main content
Glama

excel_write_worksheet

Write data arrays to Excel worksheets for financial calculations, investment analysis, and automated reporting with precise cell positioning.

Instructions

Write data to a worksheet

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataYes
startColNo
startRowNo
worksheetNameYes

Implementation Reference

  • Tool registration including name, description, input schema, and handler function for excel_write_worksheet
    { name: "excel_write_worksheet", description: "Write data to a worksheet", inputSchema: { type: "object", properties: { worksheetName: { type: "string" }, data: { type: "array", items: { type: "array" } }, startRow: { type: "number", default: 1 }, startCol: { type: "number", default: 1 } }, required: ["worksheetName", "data"] }, handler: async (args: any): Promise<ToolResult> => { try { await excelManager.writeWorksheet( args.worksheetName, args.data, args.startRow || 1, args.startCol || 1 ); return { success: true, message: `Data written to ${args.worksheetName}` }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : String(error) }; } } },
  • Core handler logic in ExcelManager that writes data to worksheet cells using ExcelJS, supports formulas, styles, creates worksheet if needed
    async writeWorksheet(worksheetName: string, data: any[][], startRow: number = 1, startCol: number = 1): Promise<void> { if (!this.workbook) { throw new Error('No workbook is currently open'); } let worksheet = this.workbook.getWorksheet(worksheetName); if (!worksheet) { worksheet = this.workbook.addWorksheet(worksheetName); } data.forEach((row, rowIndex) => { row.forEach((cellData, colIndex) => { const cell = worksheet!.getCell(startRow + rowIndex, startCol + colIndex); if (typeof cellData === 'object' && cellData !== null && !(cellData instanceof Date)) { if (cellData.formula) { // When a formula is provided, set it and let Excel calculate the value cell.value = { formula: cellData.formula }; // Note: ExcelJS will automatically calculate the value when the file is opened } else if (cellData.value !== undefined) { cell.value = cellData.value; } if (cellData.style) { Object.assign(cell, { style: cellData.style }); } } else { cell.value = cellData; } }); }); // Force calculation of all formulas this.workbook.calcProperties = { fullCalcOnLoad: true // Ensure formulas are calculated when file is opened }; }
  • src/index.ts:32-44 (registration)
    MCP server registers all tools including excelTools containing excel_write_worksheet via spread into allTools array used for listTools and callTool handlers
    const allTools = [ ...excelTools, ...financialTools, ...rentalTools, ...expenseTools, ...reportingTools, ...cashFlowTools, ...taxTools, ...analyticsTools, ...chartTools, ...complianceTools, ...propertyTools, ];

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jeremycharlesgillespie/excel-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server