Skip to main content
Glama
OfficeService.ts1.28 kB
import { DocumentAdapterFactory } from '../adapters/DocumentAdapterFactory'; import { DocumentData } from '../adapters/IDocumentAdapter'; export class OfficeService { private adapter = DocumentAdapterFactory.createAdapter(); /** * 获取当前文档数据 */ async getDocumentData(): Promise<DocumentData> { return this.adapter.getDocumentData(); } /** * 更新文档内容 */ async updateDocument(data: ArrayBuffer): Promise<void> { if (!this.adapter.validateDocument(data)) { throw new Error('无效的文档格式'); } return this.adapter.updateDocument(data); } /** * 获取文档类型 */ getDocumentType() { return this.adapter.getDocumentType(); } /** * 获取文档元数据 */ async getMetadata() { return this.adapter.getMetadata(); } /** * 检查Office是否已初始化 */ isOfficeInitialized(): boolean { return typeof Office !== 'undefined' && Office.context !== null; } /** * 等待Office初始化完成 */ async waitForOfficeInitialization(): Promise<void> { return new Promise((resolve) => { if (this.isOfficeInitialized()) { resolve(); } else { Office.onReady(() => { resolve(); }); } }); } }

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/walkingzzzy/office-mcp'

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