excel_data_validation
Apply data validation rules to Excel ranges to restrict input types, ensure data integrity, and maintain spreadsheet accuracy for financial calculations.
Instructions
Add data validation to a range
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| range | Yes | ||
| validation | Yes | ||
| worksheetName | Yes |
Implementation Reference
- src/excel/excel-manager.ts:333-350 (handler)Core handler implementation that applies data validation to the specified range in the worksheet using ExcelJS.async validateData( worksheetName: string, range: string, validation: ExcelJS.DataValidation ): Promise<void> { if (!this.workbook) { throw new Error('No workbook is currently open'); } const worksheet = this.workbook.getWorksheet(worksheetName); if (!worksheet) { throw new Error(`Worksheet "${worksheetName}" not found`); } const cells = worksheet.getCell(range); cells.dataValidation = validation; }
- src/tools/excel-tools.ts:434-475 (registration)Tool registration object defining name, description, input schema, and handler stub that calls ExcelManager.validateData.{ name: "excel_data_validation", description: "Add data validation to a range", inputSchema: { type: "object", properties: { worksheetName: { type: "string" }, range: { type: "string" }, validation: { type: "object", properties: { type: { type: "string" }, operator: { type: "string" }, formula1: { type: "string" }, formula2: { type: "string" }, allowBlank: { type: "boolean" }, showInputMessage: { type: "boolean" }, promptTitle: { type: "string" }, prompt: { type: "string" }, showErrorMessage: { type: "boolean" }, errorTitle: { type: "string" }, error: { type: "string" } } } }, required: ["worksheetName", "range", "validation"] }, handler: async (args: any): Promise<ToolResult> => { try { await excelManager.validateData(args.worksheetName, args.range, args.validation); return { success: true, message: `Added data validation to ${args.range}` }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : String(error) }; } } },
- src/tools/excel-tools.ts:437-460 (schema)Input schema defining parameters for worksheetName, range, and detailed validation rules.inputSchema: { type: "object", properties: { worksheetName: { type: "string" }, range: { type: "string" }, validation: { type: "object", properties: { type: { type: "string" }, operator: { type: "string" }, formula1: { type: "string" }, formula2: { type: "string" }, allowBlank: { type: "boolean" }, showInputMessage: { type: "boolean" }, promptTitle: { type: "string" }, prompt: { type: "string" }, showErrorMessage: { type: "boolean" }, errorTitle: { type: "string" }, error: { type: "string" } } } }, required: ["worksheetName", "range", "validation"] },
- src/index.ts:32-44 (registration)Main MCP server tool registration where excelTools (containing excel_data_validation) is included in the complete tools list.const allTools = [ ...excelTools, ...financialTools, ...rentalTools, ...expenseTools, ...reportingTools, ...cashFlowTools, ...taxTools, ...analyticsTools, ...chartTools, ...complianceTools, ...propertyTools, ];