hanseol 3.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +267 -0
- package/dist/agents/base/base-agent.d.ts +38 -0
- package/dist/agents/base/base-agent.d.ts.map +1 -0
- package/dist/agents/base/base-agent.js +69 -0
- package/dist/agents/base/base-agent.js.map +1 -0
- package/dist/agents/docs-search/index.d.ts +33 -0
- package/dist/agents/docs-search/index.d.ts.map +1 -0
- package/dist/agents/docs-search/index.js +244 -0
- package/dist/agents/docs-search/index.js.map +1 -0
- package/dist/agents/index.d.ts +4 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +4 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/planner/index.d.ts +15 -0
- package/dist/agents/planner/index.d.ts.map +1 -0
- package/dist/agents/planner/index.js +270 -0
- package/dist/agents/planner/index.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +97 -0
- package/dist/cli.js.map +1 -0
- package/dist/constants.d.ts +8 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +10 -0
- package/dist/constants.js.map +1 -0
- package/dist/core/auth/auth-manager.d.ts +23 -0
- package/dist/core/auth/auth-manager.d.ts.map +1 -0
- package/dist/core/auth/auth-manager.js +159 -0
- package/dist/core/auth/auth-manager.js.map +1 -0
- package/dist/core/auth/index.d.ts +4 -0
- package/dist/core/auth/index.d.ts.map +1 -0
- package/dist/core/auth/index.js +4 -0
- package/dist/core/auth/index.js.map +1 -0
- package/dist/core/auth/jwt-decoder.d.ts +7 -0
- package/dist/core/auth/jwt-decoder.d.ts.map +1 -0
- package/dist/core/auth/jwt-decoder.js +101 -0
- package/dist/core/auth/jwt-decoder.js.map +1 -0
- package/dist/core/auth/sso-client.d.ts +20 -0
- package/dist/core/auth/sso-client.d.ts.map +1 -0
- package/dist/core/auth/sso-client.js +164 -0
- package/dist/core/auth/sso-client.js.map +1 -0
- package/dist/core/auth/types.d.ts +45 -0
- package/dist/core/auth/types.d.ts.map +1 -0
- package/dist/core/auth/types.js +2 -0
- package/dist/core/auth/types.js.map +1 -0
- package/dist/core/compact/compact-manager.d.ts +22 -0
- package/dist/core/compact/compact-manager.d.ts.map +1 -0
- package/dist/core/compact/compact-manager.js +74 -0
- package/dist/core/compact/compact-manager.js.map +1 -0
- package/dist/core/compact/compact-prompts.d.ts +11 -0
- package/dist/core/compact/compact-prompts.d.ts.map +1 -0
- package/dist/core/compact/compact-prompts.js +80 -0
- package/dist/core/compact/compact-prompts.js.map +1 -0
- package/dist/core/compact/context-tracker.d.ts +28 -0
- package/dist/core/compact/context-tracker.d.ts.map +1 -0
- package/dist/core/compact/context-tracker.js +71 -0
- package/dist/core/compact/context-tracker.js.map +1 -0
- package/dist/core/compact/index.d.ts +4 -0
- package/dist/core/compact/index.d.ts.map +1 -0
- package/dist/core/compact/index.js +4 -0
- package/dist/core/compact/index.js.map +1 -0
- package/dist/core/config/config-manager.d.ts +43 -0
- package/dist/core/config/config-manager.d.ts.map +1 -0
- package/dist/core/config/config-manager.js +247 -0
- package/dist/core/config/config-manager.js.map +1 -0
- package/dist/core/config/index.d.ts +2 -0
- package/dist/core/config/index.d.ts.map +1 -0
- package/dist/core/config/index.js +2 -0
- package/dist/core/config/index.js.map +1 -0
- package/dist/core/docs-manager.d.ts +46 -0
- package/dist/core/docs-manager.d.ts.map +1 -0
- package/dist/core/docs-manager.js +475 -0
- package/dist/core/docs-manager.js.map +1 -0
- package/dist/core/llm/index.d.ts +2 -0
- package/dist/core/llm/index.d.ts.map +1 -0
- package/dist/core/llm/index.js +2 -0
- package/dist/core/llm/index.js.map +1 -0
- package/dist/core/llm/llm-client.d.ts +97 -0
- package/dist/core/llm/llm-client.d.ts.map +1 -0
- package/dist/core/llm/llm-client.js +1002 -0
- package/dist/core/llm/llm-client.js.map +1 -0
- package/dist/core/model-sync.d.ts +20 -0
- package/dist/core/model-sync.d.ts.map +1 -0
- package/dist/core/model-sync.js +182 -0
- package/dist/core/model-sync.js.map +1 -0
- package/dist/core/notification-manager.d.ts +23 -0
- package/dist/core/notification-manager.d.ts.map +1 -0
- package/dist/core/notification-manager.js +76 -0
- package/dist/core/notification-manager.js.map +1 -0
- package/dist/core/s3-auto-updater.d.ts +51 -0
- package/dist/core/s3-auto-updater.d.ts.map +1 -0
- package/dist/core/s3-auto-updater.js +292 -0
- package/dist/core/s3-auto-updater.js.map +1 -0
- package/dist/core/session/index.d.ts +2 -0
- package/dist/core/session/index.d.ts.map +1 -0
- package/dist/core/session/index.js +2 -0
- package/dist/core/session/index.js.map +1 -0
- package/dist/core/session/session-manager.d.ts +71 -0
- package/dist/core/session/session-manager.d.ts.map +1 -0
- package/dist/core/session/session-manager.js +235 -0
- package/dist/core/session/session-manager.js.map +1 -0
- package/dist/core/slash-command-handler.d.ts +32 -0
- package/dist/core/slash-command-handler.d.ts.map +1 -0
- package/dist/core/slash-command-handler.js +402 -0
- package/dist/core/slash-command-handler.js.map +1 -0
- package/dist/core/usage-tracker.d.ts +70 -0
- package/dist/core/usage-tracker.d.ts.map +1 -0
- package/dist/core/usage-tracker.js +251 -0
- package/dist/core/usage-tracker.js.map +1 -0
- package/dist/errors/base.d.ts +22 -0
- package/dist/errors/base.d.ts.map +1 -0
- package/dist/errors/base.js +43 -0
- package/dist/errors/base.js.map +1 -0
- package/dist/errors/file.d.ts +31 -0
- package/dist/errors/file.d.ts.map +1 -0
- package/dist/errors/file.js +110 -0
- package/dist/errors/file.js.map +1 -0
- package/dist/errors/index.d.ts +10 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +41 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/errors/llm.d.ts +26 -0
- package/dist/errors/llm.d.ts.map +1 -0
- package/dist/errors/llm.js +86 -0
- package/dist/errors/llm.js.map +1 -0
- package/dist/errors/network.d.ts +19 -0
- package/dist/errors/network.d.ts.map +1 -0
- package/dist/errors/network.js +82 -0
- package/dist/errors/network.js.map +1 -0
- package/dist/errors/validation.d.ts +19 -0
- package/dist/errors/validation.d.ts.map +1 -0
- package/dist/errors/validation.js +62 -0
- package/dist/errors/validation.js.map +1 -0
- package/dist/eval/eval-runner.d.ts +24 -0
- package/dist/eval/eval-runner.d.ts.map +1 -0
- package/dist/eval/eval-runner.js +291 -0
- package/dist/eval/eval-runner.js.map +1 -0
- package/dist/eval/index.d.ts +3 -0
- package/dist/eval/index.d.ts.map +1 -0
- package/dist/eval/index.js +3 -0
- package/dist/eval/index.js.map +1 -0
- package/dist/eval/types.d.ts +77 -0
- package/dist/eval/types.d.ts.map +1 -0
- package/dist/eval/types.js +2 -0
- package/dist/eval/types.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/orchestration/index.d.ts +4 -0
- package/dist/orchestration/index.d.ts.map +1 -0
- package/dist/orchestration/index.js +3 -0
- package/dist/orchestration/index.js.map +1 -0
- package/dist/orchestration/plan-executor.d.ts +28 -0
- package/dist/orchestration/plan-executor.d.ts.map +1 -0
- package/dist/orchestration/plan-executor.js +368 -0
- package/dist/orchestration/plan-executor.js.map +1 -0
- package/dist/orchestration/types.d.ts +65 -0
- package/dist/orchestration/types.d.ts.map +1 -0
- package/dist/orchestration/types.js +2 -0
- package/dist/orchestration/types.js.map +1 -0
- package/dist/orchestration/utils.d.ts +13 -0
- package/dist/orchestration/utils.d.ts.map +1 -0
- package/dist/orchestration/utils.js +81 -0
- package/dist/orchestration/utils.js.map +1 -0
- package/dist/prompts/agents/docs-search-decision.d.ts +6 -0
- package/dist/prompts/agents/docs-search-decision.d.ts.map +1 -0
- package/dist/prompts/agents/docs-search-decision.js +46 -0
- package/dist/prompts/agents/docs-search-decision.js.map +1 -0
- package/dist/prompts/agents/docs-search.d.ts +4 -0
- package/dist/prompts/agents/docs-search.d.ts.map +1 -0
- package/dist/prompts/agents/docs-search.js +70 -0
- package/dist/prompts/agents/docs-search.js.map +1 -0
- package/dist/prompts/agents/planning.d.ts +4 -0
- package/dist/prompts/agents/planning.d.ts.map +1 -0
- package/dist/prompts/agents/planning.js +119 -0
- package/dist/prompts/agents/planning.js.map +1 -0
- package/dist/prompts/index.d.ts +10 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +10 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/shared/codebase-rules.d.ts +4 -0
- package/dist/prompts/shared/codebase-rules.d.ts.map +1 -0
- package/dist/prompts/shared/codebase-rules.js +16 -0
- package/dist/prompts/shared/codebase-rules.js.map +1 -0
- package/dist/prompts/shared/git-rules.d.ts +2 -0
- package/dist/prompts/shared/git-rules.d.ts.map +1 -0
- package/dist/prompts/shared/git-rules.js +87 -0
- package/dist/prompts/shared/git-rules.js.map +1 -0
- package/dist/prompts/shared/language-rules.d.ts +4 -0
- package/dist/prompts/shared/language-rules.d.ts.map +1 -0
- package/dist/prompts/shared/language-rules.js +22 -0
- package/dist/prompts/shared/language-rules.js.map +1 -0
- package/dist/prompts/shared/tool-usage.d.ts +12 -0
- package/dist/prompts/shared/tool-usage.d.ts.map +1 -0
- package/dist/prompts/shared/tool-usage.js +49 -0
- package/dist/prompts/shared/tool-usage.js.map +1 -0
- package/dist/prompts/system/compact.d.ts +3 -0
- package/dist/prompts/system/compact.d.ts.map +1 -0
- package/dist/prompts/system/compact.js +73 -0
- package/dist/prompts/system/compact.js.map +1 -0
- package/dist/prompts/system/plan-execute.d.ts +3 -0
- package/dist/prompts/system/plan-execute.d.ts.map +1 -0
- package/dist/prompts/system/plan-execute.js +83 -0
- package/dist/prompts/system/plan-execute.js.map +1 -0
- package/dist/tools/browser/browser-client.d.ts +107 -0
- package/dist/tools/browser/browser-client.d.ts.map +1 -0
- package/dist/tools/browser/browser-client.js +958 -0
- package/dist/tools/browser/browser-client.js.map +1 -0
- package/dist/tools/browser/browser-tools.d.ts +17 -0
- package/dist/tools/browser/browser-tools.d.ts.map +1 -0
- package/dist/tools/browser/browser-tools.js +888 -0
- package/dist/tools/browser/browser-tools.js.map +1 -0
- package/dist/tools/browser/index.d.ts +7 -0
- package/dist/tools/browser/index.d.ts.map +1 -0
- package/dist/tools/browser/index.js +17 -0
- package/dist/tools/browser/index.js.map +1 -0
- package/dist/tools/index.d.ts +4 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +4 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/llm/agents/docs-search-tools.d.ts +17 -0
- package/dist/tools/llm/agents/docs-search-tools.d.ts.map +1 -0
- package/dist/tools/llm/agents/docs-search-tools.js +265 -0
- package/dist/tools/llm/agents/docs-search-tools.js.map +1 -0
- package/dist/tools/llm/agents/index.d.ts +4 -0
- package/dist/tools/llm/agents/index.d.ts.map +1 -0
- package/dist/tools/llm/agents/index.js +3 -0
- package/dist/tools/llm/agents/index.js.map +1 -0
- package/dist/tools/llm/index.d.ts +3 -0
- package/dist/tools/llm/index.d.ts.map +1 -0
- package/dist/tools/llm/index.js +3 -0
- package/dist/tools/llm/index.js.map +1 -0
- package/dist/tools/llm/simple/ask-user-tool.d.ts +5 -0
- package/dist/tools/llm/simple/ask-user-tool.d.ts.map +1 -0
- package/dist/tools/llm/simple/ask-user-tool.js +7 -0
- package/dist/tools/llm/simple/ask-user-tool.js.map +1 -0
- package/dist/tools/llm/simple/background-bash-tool.d.ts +30 -0
- package/dist/tools/llm/simple/background-bash-tool.d.ts.map +1 -0
- package/dist/tools/llm/simple/background-bash-tool.js +320 -0
- package/dist/tools/llm/simple/background-bash-tool.js.map +1 -0
- package/dist/tools/llm/simple/background-powershell-tool.d.ts +30 -0
- package/dist/tools/llm/simple/background-powershell-tool.d.ts.map +1 -0
- package/dist/tools/llm/simple/background-powershell-tool.js +302 -0
- package/dist/tools/llm/simple/background-powershell-tool.js.map +1 -0
- package/dist/tools/llm/simple/bash-tool.d.ts +4 -0
- package/dist/tools/llm/simple/bash-tool.d.ts.map +1 -0
- package/dist/tools/llm/simple/bash-tool.js +167 -0
- package/dist/tools/llm/simple/bash-tool.js.map +1 -0
- package/dist/tools/llm/simple/docs-search-agent-tool.d.ts +6 -0
- package/dist/tools/llm/simple/docs-search-agent-tool.d.ts.map +1 -0
- package/dist/tools/llm/simple/docs-search-agent-tool.js +104 -0
- package/dist/tools/llm/simple/docs-search-agent-tool.js.map +1 -0
- package/dist/tools/llm/simple/file-tools.d.ts +12 -0
- package/dist/tools/llm/simple/file-tools.d.ts.map +1 -0
- package/dist/tools/llm/simple/file-tools.js +597 -0
- package/dist/tools/llm/simple/file-tools.js.map +1 -0
- package/dist/tools/llm/simple/final-response-tool.d.ts +12 -0
- package/dist/tools/llm/simple/final-response-tool.d.ts.map +1 -0
- package/dist/tools/llm/simple/final-response-tool.js +107 -0
- package/dist/tools/llm/simple/final-response-tool.js.map +1 -0
- package/dist/tools/llm/simple/index.d.ts +11 -0
- package/dist/tools/llm/simple/index.d.ts.map +1 -0
- package/dist/tools/llm/simple/index.js +20 -0
- package/dist/tools/llm/simple/index.js.map +1 -0
- package/dist/tools/llm/simple/planning-tools.d.ts +5 -0
- package/dist/tools/llm/simple/planning-tools.d.ts.map +1 -0
- package/dist/tools/llm/simple/planning-tools.js +117 -0
- package/dist/tools/llm/simple/planning-tools.js.map +1 -0
- package/dist/tools/llm/simple/powershell-tool.d.ts +4 -0
- package/dist/tools/llm/simple/powershell-tool.d.ts.map +1 -0
- package/dist/tools/llm/simple/powershell-tool.js +150 -0
- package/dist/tools/llm/simple/powershell-tool.js.map +1 -0
- package/dist/tools/llm/simple/simple-tool-executor.d.ts +38 -0
- package/dist/tools/llm/simple/simple-tool-executor.d.ts.map +1 -0
- package/dist/tools/llm/simple/simple-tool-executor.js +132 -0
- package/dist/tools/llm/simple/simple-tool-executor.js.map +1 -0
- package/dist/tools/llm/simple/todo-tools.d.ts +15 -0
- package/dist/tools/llm/simple/todo-tools.d.ts.map +1 -0
- package/dist/tools/llm/simple/todo-tools.js +145 -0
- package/dist/tools/llm/simple/todo-tools.js.map +1 -0
- package/dist/tools/llm/simple/user-interaction-tools.d.ts +21 -0
- package/dist/tools/llm/simple/user-interaction-tools.d.ts.map +1 -0
- package/dist/tools/llm/simple/user-interaction-tools.js +167 -0
- package/dist/tools/llm/simple/user-interaction-tools.js.map +1 -0
- package/dist/tools/office/common/constants.d.ts +194 -0
- package/dist/tools/office/common/constants.d.ts.map +1 -0
- package/dist/tools/office/common/constants.js +169 -0
- package/dist/tools/office/common/constants.js.map +1 -0
- package/dist/tools/office/common/index.d.ts +4 -0
- package/dist/tools/office/common/index.d.ts.map +1 -0
- package/dist/tools/office/common/index.js +3 -0
- package/dist/tools/office/common/index.js.map +1 -0
- package/dist/tools/office/common/types.d.ts +82 -0
- package/dist/tools/office/common/types.d.ts.map +1 -0
- package/dist/tools/office/common/types.js +2 -0
- package/dist/tools/office/common/types.js.map +1 -0
- package/dist/tools/office/common/utils.d.ts +14 -0
- package/dist/tools/office/common/utils.d.ts.map +1 -0
- package/dist/tools/office/common/utils.js +58 -0
- package/dist/tools/office/common/utils.js.map +1 -0
- package/dist/tools/office/excel-client.d.ts +123 -0
- package/dist/tools/office/excel-client.d.ts.map +1 -0
- package/dist/tools/office/excel-client.js +1037 -0
- package/dist/tools/office/excel-client.js.map +1 -0
- package/dist/tools/office/excel-tools/cells.d.ts +10 -0
- package/dist/tools/office/excel-tools/cells.d.ts.map +1 -0
- package/dist/tools/office/excel-tools/cells.js +279 -0
- package/dist/tools/office/excel-tools/cells.js.map +1 -0
- package/dist/tools/office/excel-tools/charts.d.ts +6 -0
- package/dist/tools/office/excel-tools/charts.d.ts.map +1 -0
- package/dist/tools/office/excel-tools/charts.js +124 -0
- package/dist/tools/office/excel-tools/charts.js.map +1 -0
- package/dist/tools/office/excel-tools/comments.d.ts +6 -0
- package/dist/tools/office/excel-tools/comments.d.ts.map +1 -0
- package/dist/tools/office/excel-tools/comments.js +114 -0
- package/dist/tools/office/excel-tools/comments.js.map +1 -0
- package/dist/tools/office/excel-tools/data-ops.d.ts +10 -0
- package/dist/tools/office/excel-tools/data-ops.d.ts.map +1 -0
- package/dist/tools/office/excel-tools/data-ops.js +266 -0
- package/dist/tools/office/excel-tools/data-ops.js.map +1 -0
- package/dist/tools/office/excel-tools/export.d.ts +5 -0
- package/dist/tools/office/excel-tools/export.d.ts.map +1 -0
- package/dist/tools/office/excel-tools/export.js +75 -0
- package/dist/tools/office/excel-tools/export.js.map +1 -0
- package/dist/tools/office/excel-tools/formatting.d.ts +10 -0
- package/dist/tools/office/excel-tools/formatting.d.ts.map +1 -0
- package/dist/tools/office/excel-tools/formatting.js +276 -0
- package/dist/tools/office/excel-tools/formatting.js.map +1 -0
- package/dist/tools/office/excel-tools/index.d.ts +16 -0
- package/dist/tools/office/excel-tools/index.d.ts.map +1 -0
- package/dist/tools/office/excel-tools/index.js +42 -0
- package/dist/tools/office/excel-tools/index.js.map +1 -0
- package/dist/tools/office/excel-tools/launch.d.ts +10 -0
- package/dist/tools/office/excel-tools/launch.d.ts.map +1 -0
- package/dist/tools/office/excel-tools/launch.js +248 -0
- package/dist/tools/office/excel-tools/launch.js.map +1 -0
- package/dist/tools/office/excel-tools/media.d.ts +5 -0
- package/dist/tools/office/excel-tools/media.d.ts.map +1 -0
- package/dist/tools/office/excel-tools/media.js +84 -0
- package/dist/tools/office/excel-tools/media.js.map +1 -0
- package/dist/tools/office/excel-tools/named-ranges.d.ts +6 -0
- package/dist/tools/office/excel-tools/named-ranges.d.ts.map +1 -0
- package/dist/tools/office/excel-tools/named-ranges.js +113 -0
- package/dist/tools/office/excel-tools/named-ranges.js.map +1 -0
- package/dist/tools/office/excel-tools/protection.d.ts +5 -0
- package/dist/tools/office/excel-tools/protection.d.ts.map +1 -0
- package/dist/tools/office/excel-tools/protection.js +75 -0
- package/dist/tools/office/excel-tools/protection.js.map +1 -0
- package/dist/tools/office/excel-tools/rows-columns.d.ts +11 -0
- package/dist/tools/office/excel-tools/rows-columns.d.ts.map +1 -0
- package/dist/tools/office/excel-tools/rows-columns.js +293 -0
- package/dist/tools/office/excel-tools/rows-columns.js.map +1 -0
- package/dist/tools/office/excel-tools/sheets.d.ts +8 -0
- package/dist/tools/office/excel-tools/sheets.d.ts.map +1 -0
- package/dist/tools/office/excel-tools/sheets.js +177 -0
- package/dist/tools/office/excel-tools/sheets.js.map +1 -0
- package/dist/tools/office/excel-tools/validation.d.ts +7 -0
- package/dist/tools/office/excel-tools/validation.d.ts.map +1 -0
- package/dist/tools/office/excel-tools/validation.js +175 -0
- package/dist/tools/office/excel-tools/validation.js.map +1 -0
- package/dist/tools/office/excel-tools.d.ts +3 -0
- package/dist/tools/office/excel-tools.d.ts.map +1 -0
- package/dist/tools/office/excel-tools.js +3 -0
- package/dist/tools/office/excel-tools.js.map +1 -0
- package/dist/tools/office/index.d.ts +6 -0
- package/dist/tools/office/index.d.ts.map +1 -0
- package/dist/tools/office/index.js +9 -0
- package/dist/tools/office/index.js.map +1 -0
- package/dist/tools/office/office-client-base.d.ts +29 -0
- package/dist/tools/office/office-client-base.d.ts.map +1 -0
- package/dist/tools/office/office-client-base.js +148 -0
- package/dist/tools/office/office-client-base.js.map +1 -0
- package/dist/tools/office/office-client.d.ts +196 -0
- package/dist/tools/office/office-client.d.ts.map +1 -0
- package/dist/tools/office/office-client.js +200 -0
- package/dist/tools/office/office-client.js.map +1 -0
- package/dist/tools/office/powerpoint-client.d.ts +135 -0
- package/dist/tools/office/powerpoint-client.d.ts.map +1 -0
- package/dist/tools/office/powerpoint-client.js +1136 -0
- package/dist/tools/office/powerpoint-client.js.map +1 -0
- package/dist/tools/office/powerpoint-tools/effects.d.ts +9 -0
- package/dist/tools/office/powerpoint-tools/effects.d.ts.map +1 -0
- package/dist/tools/office/powerpoint-tools/effects.js +246 -0
- package/dist/tools/office/powerpoint-tools/effects.js.map +1 -0
- package/dist/tools/office/powerpoint-tools/export.d.ts +6 -0
- package/dist/tools/office/powerpoint-tools/export.d.ts.map +1 -0
- package/dist/tools/office/powerpoint-tools/export.js +108 -0
- package/dist/tools/office/powerpoint-tools/export.js.map +1 -0
- package/dist/tools/office/powerpoint-tools/index.d.ts +13 -0
- package/dist/tools/office/powerpoint-tools/index.d.ts.map +1 -0
- package/dist/tools/office/powerpoint-tools/index.js +33 -0
- package/dist/tools/office/powerpoint-tools/index.js.map +1 -0
- package/dist/tools/office/powerpoint-tools/launch.d.ts +9 -0
- package/dist/tools/office/powerpoint-tools/launch.d.ts.map +1 -0
- package/dist/tools/office/powerpoint-tools/launch.js +214 -0
- package/dist/tools/office/powerpoint-tools/launch.js.map +1 -0
- package/dist/tools/office/powerpoint-tools/media.d.ts +8 -0
- package/dist/tools/office/powerpoint-tools/media.d.ts.map +1 -0
- package/dist/tools/office/powerpoint-tools/media.js +211 -0
- package/dist/tools/office/powerpoint-tools/media.js.map +1 -0
- package/dist/tools/office/powerpoint-tools/notes.d.ts +8 -0
- package/dist/tools/office/powerpoint-tools/notes.d.ts.map +1 -0
- package/dist/tools/office/powerpoint-tools/notes.js +171 -0
- package/dist/tools/office/powerpoint-tools/notes.js.map +1 -0
- package/dist/tools/office/powerpoint-tools/sections.d.ts +6 -0
- package/dist/tools/office/powerpoint-tools/sections.d.ts.map +1 -0
- package/dist/tools/office/powerpoint-tools/sections.js +104 -0
- package/dist/tools/office/powerpoint-tools/sections.js.map +1 -0
- package/dist/tools/office/powerpoint-tools/shapes.d.ts +22 -0
- package/dist/tools/office/powerpoint-tools/shapes.d.ts.map +1 -0
- package/dist/tools/office/powerpoint-tools/shapes.js +681 -0
- package/dist/tools/office/powerpoint-tools/shapes.js.map +1 -0
- package/dist/tools/office/powerpoint-tools/slides.d.ts +11 -0
- package/dist/tools/office/powerpoint-tools/slides.d.ts.map +1 -0
- package/dist/tools/office/powerpoint-tools/slides.js +283 -0
- package/dist/tools/office/powerpoint-tools/slides.js.map +1 -0
- package/dist/tools/office/powerpoint-tools/tables.d.ts +6 -0
- package/dist/tools/office/powerpoint-tools/tables.d.ts.map +1 -0
- package/dist/tools/office/powerpoint-tools/tables.js +132 -0
- package/dist/tools/office/powerpoint-tools/tables.js.map +1 -0
- package/dist/tools/office/powerpoint-tools/text.d.ts +12 -0
- package/dist/tools/office/powerpoint-tools/text.d.ts.map +1 -0
- package/dist/tools/office/powerpoint-tools/text.js +366 -0
- package/dist/tools/office/powerpoint-tools/text.js.map +1 -0
- package/dist/tools/office/powerpoint-tools.d.ts +3 -0
- package/dist/tools/office/powerpoint-tools.d.ts.map +1 -0
- package/dist/tools/office/powerpoint-tools.js +3 -0
- package/dist/tools/office/powerpoint-tools.js.map +1 -0
- package/dist/tools/office/word-client.d.ts +111 -0
- package/dist/tools/office/word-client.d.ts.map +1 -0
- package/dist/tools/office/word-client.js +995 -0
- package/dist/tools/office/word-client.js.map +1 -0
- package/dist/tools/office/word-tools/bookmarks.d.ts +7 -0
- package/dist/tools/office/word-tools/bookmarks.d.ts.map +1 -0
- package/dist/tools/office/word-tools/bookmarks.js +146 -0
- package/dist/tools/office/word-tools/bookmarks.js.map +1 -0
- package/dist/tools/office/word-tools/comments.d.ts +7 -0
- package/dist/tools/office/word-tools/comments.d.ts.map +1 -0
- package/dist/tools/office/word-tools/comments.js +146 -0
- package/dist/tools/office/word-tools/comments.js.map +1 -0
- package/dist/tools/office/word-tools/content.d.ts +7 -0
- package/dist/tools/office/word-tools/content.d.ts.map +1 -0
- package/dist/tools/office/word-tools/content.js +168 -0
- package/dist/tools/office/word-tools/content.js.map +1 -0
- package/dist/tools/office/word-tools/export.d.ts +5 -0
- package/dist/tools/office/word-tools/export.d.ts.map +1 -0
- package/dist/tools/office/word-tools/export.js +73 -0
- package/dist/tools/office/word-tools/export.js.map +1 -0
- package/dist/tools/office/word-tools/formatting.d.ts +6 -0
- package/dist/tools/office/word-tools/formatting.d.ts.map +1 -0
- package/dist/tools/office/word-tools/formatting.js +129 -0
- package/dist/tools/office/word-tools/formatting.js.map +1 -0
- package/dist/tools/office/word-tools/headers-footers.d.ts +6 -0
- package/dist/tools/office/word-tools/headers-footers.d.ts.map +1 -0
- package/dist/tools/office/word-tools/headers-footers.js +117 -0
- package/dist/tools/office/word-tools/headers-footers.js.map +1 -0
- package/dist/tools/office/word-tools/index.d.ts +16 -0
- package/dist/tools/office/word-tools/index.d.ts.map +1 -0
- package/dist/tools/office/word-tools/index.js +45 -0
- package/dist/tools/office/word-tools/index.js.map +1 -0
- package/dist/tools/office/word-tools/launch.d.ts +10 -0
- package/dist/tools/office/word-tools/launch.d.ts.map +1 -0
- package/dist/tools/office/word-tools/launch.js +255 -0
- package/dist/tools/office/word-tools/launch.js.map +1 -0
- package/dist/tools/office/word-tools/lists.d.ts +5 -0
- package/dist/tools/office/word-tools/lists.d.ts.map +1 -0
- package/dist/tools/office/word-tools/lists.js +73 -0
- package/dist/tools/office/word-tools/lists.js.map +1 -0
- package/dist/tools/office/word-tools/navigation.d.ts +5 -0
- package/dist/tools/office/word-tools/navigation.d.ts.map +1 -0
- package/dist/tools/office/word-tools/navigation.js +85 -0
- package/dist/tools/office/word-tools/navigation.js.map +1 -0
- package/dist/tools/office/word-tools/page-setup.d.ts +7 -0
- package/dist/tools/office/word-tools/page-setup.d.ts.map +1 -0
- package/dist/tools/office/word-tools/page-setup.js +152 -0
- package/dist/tools/office/word-tools/page-setup.js.map +1 -0
- package/dist/tools/office/word-tools/tables.d.ts +8 -0
- package/dist/tools/office/word-tools/tables.d.ts.map +1 -0
- package/dist/tools/office/word-tools/tables.js +197 -0
- package/dist/tools/office/word-tools/tables.js.map +1 -0
- package/dist/tools/office/word-tools/text.d.ts +9 -0
- package/dist/tools/office/word-tools/text.d.ts.map +1 -0
- package/dist/tools/office/word-tools/text.js +235 -0
- package/dist/tools/office/word-tools/text.js.map +1 -0
- package/dist/tools/office/word-tools/undo-redo.d.ts +5 -0
- package/dist/tools/office/word-tools/undo-redo.d.ts.map +1 -0
- package/dist/tools/office/word-tools/undo-redo.js +73 -0
- package/dist/tools/office/word-tools/undo-redo.js.map +1 -0
- package/dist/tools/office/word-tools/watermarks.d.ts +5 -0
- package/dist/tools/office/word-tools/watermarks.d.ts.map +1 -0
- package/dist/tools/office/word-tools/watermarks.js +81 -0
- package/dist/tools/office/word-tools/watermarks.js.map +1 -0
- package/dist/tools/office/word-tools.d.ts +3 -0
- package/dist/tools/office/word-tools.d.ts.map +1 -0
- package/dist/tools/office/word-tools.js +3 -0
- package/dist/tools/office/word-tools.js.map +1 -0
- package/dist/tools/registry.d.ts +46 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +258 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/types.d.ts +88 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +19 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/types/index.d.ts +122 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/ui/PlanExecuteView.d.ts +11 -0
- package/dist/ui/PlanExecuteView.d.ts.map +1 -0
- package/dist/ui/PlanExecuteView.js +27 -0
- package/dist/ui/PlanExecuteView.js.map +1 -0
- package/dist/ui/TodoPanel.d.ts +13 -0
- package/dist/ui/TodoPanel.d.ts.map +1 -0
- package/dist/ui/TodoPanel.js +135 -0
- package/dist/ui/TodoPanel.js.map +1 -0
- package/dist/ui/UpdateNotification.d.ts +13 -0
- package/dist/ui/UpdateNotification.d.ts.map +1 -0
- package/dist/ui/UpdateNotification.js +42 -0
- package/dist/ui/UpdateNotification.js.map +1 -0
- package/dist/ui/components/ActivityIndicator.d.ts +25 -0
- package/dist/ui/components/ActivityIndicator.d.ts.map +1 -0
- package/dist/ui/components/ActivityIndicator.js +115 -0
- package/dist/ui/components/ActivityIndicator.js.map +1 -0
- package/dist/ui/components/CommandBrowser.d.ts +10 -0
- package/dist/ui/components/CommandBrowser.d.ts.map +1 -0
- package/dist/ui/components/CommandBrowser.js +53 -0
- package/dist/ui/components/CommandBrowser.js.map +1 -0
- package/dist/ui/components/CustomTextInput.d.ts +13 -0
- package/dist/ui/components/CustomTextInput.d.ts.map +1 -0
- package/dist/ui/components/CustomTextInput.js +245 -0
- package/dist/ui/components/CustomTextInput.js.map +1 -0
- package/dist/ui/components/DocsSearchProgress.d.ts +13 -0
- package/dist/ui/components/DocsSearchProgress.d.ts.map +1 -0
- package/dist/ui/components/DocsSearchProgress.js +37 -0
- package/dist/ui/components/DocsSearchProgress.js.map +1 -0
- package/dist/ui/components/FileBrowser.d.ts +11 -0
- package/dist/ui/components/FileBrowser.d.ts.map +1 -0
- package/dist/ui/components/FileBrowser.js +45 -0
- package/dist/ui/components/FileBrowser.js.map +1 -0
- package/dist/ui/components/LLMSetupWizard.d.ts +8 -0
- package/dist/ui/components/LLMSetupWizard.d.ts.map +1 -0
- package/dist/ui/components/LLMSetupWizard.js +183 -0
- package/dist/ui/components/LLMSetupWizard.js.map +1 -0
- package/dist/ui/components/Logo.d.ts +19 -0
- package/dist/ui/components/Logo.d.ts.map +1 -0
- package/dist/ui/components/Logo.js +99 -0
- package/dist/ui/components/Logo.js.map +1 -0
- package/dist/ui/components/MarkdownRenderer.d.ts +9 -0
- package/dist/ui/components/MarkdownRenderer.d.ts.map +1 -0
- package/dist/ui/components/MarkdownRenderer.js +198 -0
- package/dist/ui/components/MarkdownRenderer.js.map +1 -0
- package/dist/ui/components/ModelSelector.d.ts +8 -0
- package/dist/ui/components/ModelSelector.d.ts.map +1 -0
- package/dist/ui/components/ModelSelector.js +111 -0
- package/dist/ui/components/ModelSelector.js.map +1 -0
- package/dist/ui/components/PlanExecuteApp.d.ts +23 -0
- package/dist/ui/components/PlanExecuteApp.d.ts.map +1 -0
- package/dist/ui/components/PlanExecuteApp.js +1432 -0
- package/dist/ui/components/PlanExecuteApp.js.map +1 -0
- package/dist/ui/components/ProgressBar.d.ts +10 -0
- package/dist/ui/components/ProgressBar.d.ts.map +1 -0
- package/dist/ui/components/ProgressBar.js +26 -0
- package/dist/ui/components/ProgressBar.js.map +1 -0
- package/dist/ui/components/StatusBar.d.ts +23 -0
- package/dist/ui/components/StatusBar.d.ts.map +1 -0
- package/dist/ui/components/StatusBar.js +162 -0
- package/dist/ui/components/StatusBar.js.map +1 -0
- package/dist/ui/components/ThinkingIndicator.d.ts +14 -0
- package/dist/ui/components/ThinkingIndicator.d.ts.map +1 -0
- package/dist/ui/components/ThinkingIndicator.js +63 -0
- package/dist/ui/components/ThinkingIndicator.js.map +1 -0
- package/dist/ui/components/TodoListView.d.ts +11 -0
- package/dist/ui/components/TodoListView.d.ts.map +1 -0
- package/dist/ui/components/TodoListView.js +69 -0
- package/dist/ui/components/TodoListView.js.map +1 -0
- package/dist/ui/components/ToolSelector.d.ts +7 -0
- package/dist/ui/components/ToolSelector.d.ts.map +1 -0
- package/dist/ui/components/ToolSelector.js +112 -0
- package/dist/ui/components/ToolSelector.js.map +1 -0
- package/dist/ui/components/dialogs/ApprovalDialog.d.ts +13 -0
- package/dist/ui/components/dialogs/ApprovalDialog.d.ts.map +1 -0
- package/dist/ui/components/dialogs/ApprovalDialog.js +173 -0
- package/dist/ui/components/dialogs/ApprovalDialog.js.map +1 -0
- package/dist/ui/components/dialogs/AskUserDialog.d.ts +9 -0
- package/dist/ui/components/dialogs/AskUserDialog.d.ts.map +1 -0
- package/dist/ui/components/dialogs/AskUserDialog.js +111 -0
- package/dist/ui/components/dialogs/AskUserDialog.js.map +1 -0
- package/dist/ui/components/dialogs/DocsBrowser.d.ts +8 -0
- package/dist/ui/components/dialogs/DocsBrowser.d.ts.map +1 -0
- package/dist/ui/components/dialogs/DocsBrowser.js +127 -0
- package/dist/ui/components/dialogs/DocsBrowser.js.map +1 -0
- package/dist/ui/components/dialogs/RatingDialog.d.ts +9 -0
- package/dist/ui/components/dialogs/RatingDialog.d.ts.map +1 -0
- package/dist/ui/components/dialogs/RatingDialog.js +54 -0
- package/dist/ui/components/dialogs/RatingDialog.js.map +1 -0
- package/dist/ui/components/dialogs/SettingsDialog.d.ts +10 -0
- package/dist/ui/components/dialogs/SettingsDialog.d.ts.map +1 -0
- package/dist/ui/components/dialogs/SettingsDialog.js +563 -0
- package/dist/ui/components/dialogs/SettingsDialog.js.map +1 -0
- package/dist/ui/components/dialogs/index.d.ts +4 -0
- package/dist/ui/components/dialogs/index.d.ts.map +1 -0
- package/dist/ui/components/dialogs/index.js +4 -0
- package/dist/ui/components/dialogs/index.js.map +1 -0
- package/dist/ui/components/index.d.ts +12 -0
- package/dist/ui/components/index.d.ts.map +1 -0
- package/dist/ui/components/index.js +9 -0
- package/dist/ui/components/index.js.map +1 -0
- package/dist/ui/components/panels/SessionPanel.d.ts +8 -0
- package/dist/ui/components/panels/SessionPanel.d.ts.map +1 -0
- package/dist/ui/components/panels/SessionPanel.js +81 -0
- package/dist/ui/components/panels/SessionPanel.js.map +1 -0
- package/dist/ui/components/panels/index.d.ts +3 -0
- package/dist/ui/components/panels/index.d.ts.map +1 -0
- package/dist/ui/components/panels/index.js +3 -0
- package/dist/ui/components/panels/index.js.map +1 -0
- package/dist/ui/components/views/ChatView.d.ts +12 -0
- package/dist/ui/components/views/ChatView.d.ts.map +1 -0
- package/dist/ui/components/views/ChatView.js +289 -0
- package/dist/ui/components/views/ChatView.js.map +1 -0
- package/dist/ui/components/views/index.d.ts +2 -0
- package/dist/ui/components/views/index.d.ts.map +1 -0
- package/dist/ui/components/views/index.js +2 -0
- package/dist/ui/components/views/index.js.map +1 -0
- package/dist/ui/contexts/TokenContext.d.ts +29 -0
- package/dist/ui/contexts/TokenContext.d.ts.map +1 -0
- package/dist/ui/contexts/TokenContext.js +79 -0
- package/dist/ui/contexts/TokenContext.js.map +1 -0
- package/dist/ui/hooks/atFileProcessor.d.ts +15 -0
- package/dist/ui/hooks/atFileProcessor.d.ts.map +1 -0
- package/dist/ui/hooks/atFileProcessor.js +88 -0
- package/dist/ui/hooks/atFileProcessor.js.map +1 -0
- package/dist/ui/hooks/index.d.ts +8 -0
- package/dist/ui/hooks/index.d.ts.map +1 -0
- package/dist/ui/hooks/index.js +8 -0
- package/dist/ui/hooks/index.js.map +1 -0
- package/dist/ui/hooks/slashCommandProcessor.d.ts +21 -0
- package/dist/ui/hooks/slashCommandProcessor.d.ts.map +1 -0
- package/dist/ui/hooks/slashCommandProcessor.js +100 -0
- package/dist/ui/hooks/slashCommandProcessor.js.map +1 -0
- package/dist/ui/hooks/useCommandBrowserState.d.ts +12 -0
- package/dist/ui/hooks/useCommandBrowserState.d.ts.map +1 -0
- package/dist/ui/hooks/useCommandBrowserState.js +66 -0
- package/dist/ui/hooks/useCommandBrowserState.js.map +1 -0
- package/dist/ui/hooks/useFileBrowserState.d.ts +15 -0
- package/dist/ui/hooks/useFileBrowserState.d.ts.map +1 -0
- package/dist/ui/hooks/useFileBrowserState.js +79 -0
- package/dist/ui/hooks/useFileBrowserState.js.map +1 -0
- package/dist/ui/hooks/useFileList.d.ts +20 -0
- package/dist/ui/hooks/useFileList.d.ts.map +1 -0
- package/dist/ui/hooks/useFileList.js +56 -0
- package/dist/ui/hooks/useFileList.js.map +1 -0
- package/dist/ui/hooks/useInputHistory.d.ts +9 -0
- package/dist/ui/hooks/useInputHistory.d.ts.map +1 -0
- package/dist/ui/hooks/useInputHistory.js +68 -0
- package/dist/ui/hooks/useInputHistory.js.map +1 -0
- package/dist/ui/hooks/usePlanExecution.d.ts +8 -0
- package/dist/ui/hooks/usePlanExecution.d.ts.map +1 -0
- package/dist/ui/hooks/usePlanExecution.js +208 -0
- package/dist/ui/hooks/usePlanExecution.js.map +1 -0
- package/dist/ui/index.d.ts +7 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +7 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/ink-entry.d.ts +3 -0
- package/dist/ui/ink-entry.d.ts.map +1 -0
- package/dist/ui/ink-entry.js +21 -0
- package/dist/ui/ink-entry.js.map +1 -0
- package/dist/utils/file-system.d.ts +9 -0
- package/dist/utils/file-system.d.ts.map +1 -0
- package/dist/utils/file-system.js +99 -0
- package/dist/utils/file-system.js.map +1 -0
- package/dist/utils/git-utils.d.ts +2 -0
- package/dist/utils/git-utils.d.ts.map +1 -0
- package/dist/utils/git-utils.js +16 -0
- package/dist/utils/git-utils.js.map +1 -0
- package/dist/utils/json-stream-logger.d.ts +52 -0
- package/dist/utils/json-stream-logger.d.ts.map +1 -0
- package/dist/utils/json-stream-logger.js +442 -0
- package/dist/utils/json-stream-logger.js.map +1 -0
- package/dist/utils/logger.d.ts +86 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +588 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/platform-utils.d.ts +19 -0
- package/dist/utils/platform-utils.d.ts.map +1 -0
- package/dist/utils/platform-utils.js +134 -0
- package/dist/utils/platform-utils.js.map +1 -0
- package/dist/utils/wsl-utils.d.ts +4 -0
- package/dist/utils/wsl-utils.d.ts.map +1 -0
- package/dist/utils/wsl-utils.js +72 -0
- package/dist/utils/wsl-utils.js.map +1 -0
- package/package.json +150 -0
- package/scripts/patch-yoga.js +48 -0
|
@@ -0,0 +1,1037 @@
|
|
|
1
|
+
import { OfficeClientBase } from './office-client-base.js';
|
|
2
|
+
function columnLetterToNumber(column) {
|
|
3
|
+
let result = 0;
|
|
4
|
+
for (let i = 0; i < column.length; i++) {
|
|
5
|
+
result = result * 26 + (column.charCodeAt(i) - 'A'.charCodeAt(0) + 1);
|
|
6
|
+
}
|
|
7
|
+
return result;
|
|
8
|
+
}
|
|
9
|
+
function columnNumberToLetter(num) {
|
|
10
|
+
let result = '';
|
|
11
|
+
while (num > 0) {
|
|
12
|
+
num--;
|
|
13
|
+
result = String.fromCharCode('A'.charCodeAt(0) + (num % 26)) + result;
|
|
14
|
+
num = Math.floor(num / 26);
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
export class ExcelClient extends OfficeClientBase {
|
|
19
|
+
async excelLaunch() {
|
|
20
|
+
return this.executePowerShell(`
|
|
21
|
+
try {
|
|
22
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
23
|
+
$excel.Visible = $true
|
|
24
|
+
@{ success = $true; message = "Connected to existing Excel instance" } | ConvertTo-Json -Compress
|
|
25
|
+
} catch {
|
|
26
|
+
$excel = New-Object -ComObject Excel.Application
|
|
27
|
+
$excel.Visible = $true
|
|
28
|
+
@{ success = $true; message = "Launched new Excel instance" } | ConvertTo-Json -Compress
|
|
29
|
+
}
|
|
30
|
+
`);
|
|
31
|
+
}
|
|
32
|
+
async excelCreate() {
|
|
33
|
+
return this.executePowerShell(`
|
|
34
|
+
try {
|
|
35
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
36
|
+
} catch {
|
|
37
|
+
$excel = New-Object -ComObject Excel.Application
|
|
38
|
+
$excel.Visible = $true
|
|
39
|
+
}
|
|
40
|
+
$workbook = $excel.Workbooks.Add()
|
|
41
|
+
@{ success = $true; message = "Created new workbook"; workbook_name = $workbook.Name } | ConvertTo-Json -Compress
|
|
42
|
+
`);
|
|
43
|
+
}
|
|
44
|
+
async excelOpen(filePath) {
|
|
45
|
+
const windowsPath = this.toWindowsPath(filePath).replace(/'/g, "''");
|
|
46
|
+
return this.executePowerShell(`
|
|
47
|
+
try {
|
|
48
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
49
|
+
} catch {
|
|
50
|
+
$excel = New-Object -ComObject Excel.Application
|
|
51
|
+
$excel.Visible = $true
|
|
52
|
+
}
|
|
53
|
+
$workbook = $excel.Workbooks.Open('${windowsPath}')
|
|
54
|
+
@{ success = $true; message = "Workbook opened"; workbook_name = $workbook.Name; path = $workbook.FullName } | ConvertTo-Json -Compress
|
|
55
|
+
`);
|
|
56
|
+
}
|
|
57
|
+
async excelWriteCell(cell, value, sheet, options) {
|
|
58
|
+
const strValue = String(value);
|
|
59
|
+
const escapedValue = strValue.replace(/'/g, "''");
|
|
60
|
+
const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
|
|
61
|
+
const hasKorean = /[가-힣ㄱ-ㅎㅏ-ㅣ]/.test(strValue);
|
|
62
|
+
const fontName = options?.fontName || (hasKorean ? 'Malgun Gothic' : '');
|
|
63
|
+
const fontScript = [];
|
|
64
|
+
if (fontName)
|
|
65
|
+
fontScript.push(`$range.Font.Name = '${fontName.replace(/'/g, "''")}'`);
|
|
66
|
+
if (options?.fontSize)
|
|
67
|
+
fontScript.push(`$range.Font.Size = ${options.fontSize}`);
|
|
68
|
+
if (options?.bold !== undefined)
|
|
69
|
+
fontScript.push(`$range.Font.Bold = ${options.bold ? '$true' : '$false'}`);
|
|
70
|
+
let valueScript;
|
|
71
|
+
if (options?.asText) {
|
|
72
|
+
valueScript = `$range.NumberFormat = '@'; $range.Value = '${escapedValue}'`;
|
|
73
|
+
}
|
|
74
|
+
else if (typeof value === 'number' || (strValue !== '' && !isNaN(Number(strValue)) && strValue.trim() !== '')) {
|
|
75
|
+
valueScript = `$range.Value = ${strValue}`;
|
|
76
|
+
}
|
|
77
|
+
else if (/^\d{4}-\d{2}-\d{2}$/.test(strValue)) {
|
|
78
|
+
const [year, month, day] = strValue.split('-');
|
|
79
|
+
valueScript = `$range.Value = (Get-Date -Year ${year} -Month ${month} -Day ${day}).ToOADate()`;
|
|
80
|
+
}
|
|
81
|
+
else if (/^\d{1,2}\/\d{1,2}\/\d{4}$/.test(strValue)) {
|
|
82
|
+
valueScript = `$range.Value = '${escapedValue}'`;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
valueScript = `$range.Value = '${escapedValue}'`;
|
|
86
|
+
}
|
|
87
|
+
return this.executePowerShell(`
|
|
88
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
89
|
+
$workbook = $excel.ActiveWorkbook
|
|
90
|
+
${sheetScript}
|
|
91
|
+
$range = $sheet.Range('${cell}')
|
|
92
|
+
${valueScript}
|
|
93
|
+
${fontScript.join('\n')}
|
|
94
|
+
@{ success = $true; message = "Value written to ${cell}" } | ConvertTo-Json -Compress
|
|
95
|
+
`);
|
|
96
|
+
}
|
|
97
|
+
async excelReadCell(cell, sheet) {
|
|
98
|
+
const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
|
|
99
|
+
return this.executePowerShell(`
|
|
100
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
101
|
+
$workbook = $excel.ActiveWorkbook
|
|
102
|
+
${sheetScript}
|
|
103
|
+
$value = $sheet.Range('${cell}').Value2
|
|
104
|
+
@{ success = $true; cell = '${cell}'; value = $value } | ConvertTo-Json -Compress
|
|
105
|
+
`);
|
|
106
|
+
}
|
|
107
|
+
async excelWriteRange(startCell, values, sheet) {
|
|
108
|
+
const rows = values.length;
|
|
109
|
+
const cols = values[0]?.length || 0;
|
|
110
|
+
const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
|
|
111
|
+
let hasKorean = false;
|
|
112
|
+
const toPsValue = (v) => {
|
|
113
|
+
const str = String(v);
|
|
114
|
+
if (/[가-힣ㄱ-ㅎㅏ-ㅣ]/.test(str))
|
|
115
|
+
hasKorean = true;
|
|
116
|
+
if (typeof v === 'number' || (str !== '' && !isNaN(Number(str)) && str.trim() !== '')) {
|
|
117
|
+
return str;
|
|
118
|
+
}
|
|
119
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(str)) {
|
|
120
|
+
const [year, month, day] = str.split('-');
|
|
121
|
+
return `([DateTime]::new(${year},${month},${day})).ToOADate()`;
|
|
122
|
+
}
|
|
123
|
+
return `'${str.replace(/'/g, "''")}'`;
|
|
124
|
+
};
|
|
125
|
+
const arrayLines = [];
|
|
126
|
+
for (let i = 0; i < values.length; i++) {
|
|
127
|
+
const row = values[i];
|
|
128
|
+
if (!row)
|
|
129
|
+
continue;
|
|
130
|
+
const rowValues = row.map(v => toPsValue(v)).join(',');
|
|
131
|
+
arrayLines.push(`@(${rowValues})`);
|
|
132
|
+
}
|
|
133
|
+
const arrayScript = `@(${arrayLines.join(',')})`;
|
|
134
|
+
const fontScript = hasKorean ? "$range.Font.Name = 'Malgun Gothic'" : '';
|
|
135
|
+
return this.executePowerShell(`
|
|
136
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
137
|
+
$workbook = $excel.ActiveWorkbook
|
|
138
|
+
${sheetScript}
|
|
139
|
+
$startRange = $sheet.Range('${startCell}')
|
|
140
|
+
$endCell = $sheet.Cells($startRange.Row + ${rows - 1}, $startRange.Column + ${cols - 1})
|
|
141
|
+
$range = $sheet.Range($startRange, $endCell)
|
|
142
|
+
$data = ${arrayScript}
|
|
143
|
+
$range.Value = $data
|
|
144
|
+
${fontScript}
|
|
145
|
+
@{ success = $true; message = "Range written from ${startCell} (${rows}x${cols})" } | ConvertTo-Json -Compress
|
|
146
|
+
`);
|
|
147
|
+
}
|
|
148
|
+
async excelReadRange(range, sheet) {
|
|
149
|
+
const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
|
|
150
|
+
return this.executePowerShell(`
|
|
151
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
152
|
+
$workbook = $excel.ActiveWorkbook
|
|
153
|
+
${sheetScript}
|
|
154
|
+
$range = $sheet.Range('${range}')
|
|
155
|
+
$values = $range.Value2
|
|
156
|
+
$rows = $range.Rows.Count
|
|
157
|
+
$cols = $range.Columns.Count
|
|
158
|
+
@{ success = $true; range = '${range}'; values = $values; rows = $rows; columns = $cols } | ConvertTo-Json -Compress -Depth 10
|
|
159
|
+
`);
|
|
160
|
+
}
|
|
161
|
+
async excelSave(filePath) {
|
|
162
|
+
const windowsPath = filePath ? this.toWindowsPath(filePath).replace(/'/g, "''") : '';
|
|
163
|
+
return this.executePowerShell(`
|
|
164
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
165
|
+
$workbook = $excel.ActiveWorkbook
|
|
166
|
+
${windowsPath ? `$workbook.SaveAs('${windowsPath}')` : '$workbook.Save()'}
|
|
167
|
+
@{ success = $true; message = "Workbook saved"; path = $workbook.FullName } | ConvertTo-Json -Compress
|
|
168
|
+
`);
|
|
169
|
+
}
|
|
170
|
+
async excelClose(save = false) {
|
|
171
|
+
return this.executePowerShell(`
|
|
172
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
173
|
+
$workbook = $excel.ActiveWorkbook
|
|
174
|
+
$workbook.Close(${save ? '$true' : '$false'})
|
|
175
|
+
@{ success = $true; message = "Workbook closed" } | ConvertTo-Json -Compress
|
|
176
|
+
`);
|
|
177
|
+
}
|
|
178
|
+
async excelQuit(save = false) {
|
|
179
|
+
return this.executePowerShell(`
|
|
180
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
181
|
+
if (${save ? '$true' : '$false'}) {
|
|
182
|
+
foreach ($wb in $excel.Workbooks) { $wb.Save() }
|
|
183
|
+
}
|
|
184
|
+
$excel.Quit()
|
|
185
|
+
@{ success = $true; message = "Excel closed" } | ConvertTo-Json -Compress
|
|
186
|
+
`);
|
|
187
|
+
}
|
|
188
|
+
async excelSetFormula(cell, formula, sheet) {
|
|
189
|
+
const escapedFormula = formula.replace(/'/g, "''");
|
|
190
|
+
const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
|
|
191
|
+
return this.executePowerShell(`
|
|
192
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
193
|
+
$workbook = $excel.ActiveWorkbook
|
|
194
|
+
${sheetScript}
|
|
195
|
+
$sheet.Range('${cell}').Formula = '${escapedFormula}'
|
|
196
|
+
@{ success = $true; message = "Formula set in ${cell}" } | ConvertTo-Json -Compress
|
|
197
|
+
`);
|
|
198
|
+
}
|
|
199
|
+
async excelSetFont(range, options, sheet) {
|
|
200
|
+
const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
|
|
201
|
+
const commands = [];
|
|
202
|
+
if (options.fontName)
|
|
203
|
+
commands.push(`$range.Font.Name = '${options.fontName.replace(/'/g, "''")}'`);
|
|
204
|
+
if (options.fontSize)
|
|
205
|
+
commands.push(`$range.Font.Size = ${options.fontSize}`);
|
|
206
|
+
if (options.bold !== undefined)
|
|
207
|
+
commands.push(`$range.Font.Bold = ${options.bold ? '$true' : '$false'}`);
|
|
208
|
+
if (options.italic !== undefined)
|
|
209
|
+
commands.push(`$range.Font.Italic = ${options.italic ? '$true' : '$false'}`);
|
|
210
|
+
if (options.underline !== undefined)
|
|
211
|
+
commands.push(`$range.Font.Underline = ${options.underline ? '2' : '0'}`);
|
|
212
|
+
if (options.color) {
|
|
213
|
+
const rgb = this.hexToRgb(options.color);
|
|
214
|
+
if (rgb)
|
|
215
|
+
commands.push(`$range.Font.Color = ${rgb.r + rgb.g * 256 + rgb.b * 65536}`);
|
|
216
|
+
}
|
|
217
|
+
return this.executePowerShell(`
|
|
218
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
219
|
+
$workbook = $excel.ActiveWorkbook
|
|
220
|
+
${sheetScript}
|
|
221
|
+
$range = $sheet.Range('${range}')
|
|
222
|
+
${commands.join('\n')}
|
|
223
|
+
@{ success = $true; message = "Font properties set for ${range}" } | ConvertTo-Json -Compress
|
|
224
|
+
`);
|
|
225
|
+
}
|
|
226
|
+
async excelSetAlignment(range, options, sheet) {
|
|
227
|
+
const hAlignMap = { left: -4131, center: -4108, right: -4152 };
|
|
228
|
+
const vAlignMap = { top: -4160, center: -4108, bottom: -4107 };
|
|
229
|
+
const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
|
|
230
|
+
const commands = [];
|
|
231
|
+
if (options.horizontal)
|
|
232
|
+
commands.push(`$range.HorizontalAlignment = ${hAlignMap[options.horizontal]}`);
|
|
233
|
+
if (options.vertical)
|
|
234
|
+
commands.push(`$range.VerticalAlignment = ${vAlignMap[options.vertical]}`);
|
|
235
|
+
if (options.wrapText !== undefined)
|
|
236
|
+
commands.push(`$range.WrapText = ${options.wrapText ? '$true' : '$false'}`);
|
|
237
|
+
if (options.orientation !== undefined)
|
|
238
|
+
commands.push(`$range.Orientation = ${options.orientation}`);
|
|
239
|
+
return this.executePowerShell(`
|
|
240
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
241
|
+
$workbook = $excel.ActiveWorkbook
|
|
242
|
+
${sheetScript}
|
|
243
|
+
$range = $sheet.Range('${range}')
|
|
244
|
+
${commands.join('\n')}
|
|
245
|
+
@{ success = $true; message = "Alignment set for ${range}" } | ConvertTo-Json -Compress
|
|
246
|
+
`);
|
|
247
|
+
}
|
|
248
|
+
async excelSetColumnWidth(column, width, autoFit, sheet) {
|
|
249
|
+
const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
|
|
250
|
+
return this.executePowerShell(`
|
|
251
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
252
|
+
$workbook = $excel.ActiveWorkbook
|
|
253
|
+
${sheetScript}
|
|
254
|
+
$col = $sheet.Columns('${column}')
|
|
255
|
+
${autoFit ? '$col.AutoFit()' : `$col.ColumnWidth = ${width || 10}`}
|
|
256
|
+
@{ success = $true; message = "Column ${column} width set" } | ConvertTo-Json -Compress
|
|
257
|
+
`);
|
|
258
|
+
}
|
|
259
|
+
async excelSetRowHeight(row, height, autoFit, sheet) {
|
|
260
|
+
const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
|
|
261
|
+
return this.executePowerShell(`
|
|
262
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
263
|
+
$workbook = $excel.ActiveWorkbook
|
|
264
|
+
${sheetScript}
|
|
265
|
+
$row = $sheet.Rows(${row})
|
|
266
|
+
${autoFit ? '$row.AutoFit()' : `$row.RowHeight = ${height || 15}`}
|
|
267
|
+
@{ success = $true; message = "Row ${row} height set" } | ConvertTo-Json -Compress
|
|
268
|
+
`);
|
|
269
|
+
}
|
|
270
|
+
async excelMergeCells(range, sheet) {
|
|
271
|
+
const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
|
|
272
|
+
return this.executePowerShell(`
|
|
273
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
274
|
+
$workbook = $excel.ActiveWorkbook
|
|
275
|
+
${sheetScript}
|
|
276
|
+
$sheet.Range('${range}').Merge()
|
|
277
|
+
@{ success = $true; message = "Cells merged: ${range}" } | ConvertTo-Json -Compress
|
|
278
|
+
`);
|
|
279
|
+
}
|
|
280
|
+
async excelSetBorder(range, options, sheet) {
|
|
281
|
+
const styleMap = { thin: 1, medium: 1, thick: 1, double: -4119, dotted: -4118, dashed: -4115 };
|
|
282
|
+
const weightMap = { thin: 2, medium: -4138, thick: 4, double: 2, dotted: 2, dashed: 2 };
|
|
283
|
+
const edgeMap = { left: 7, right: 10, top: 8, bottom: 9, all: -1 };
|
|
284
|
+
const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
|
|
285
|
+
const edges = options.edges || ['all'];
|
|
286
|
+
const borderStyle = options.style ? styleMap[options.style] : 1;
|
|
287
|
+
const borderWeight = options.style ? weightMap[options.style] : 2;
|
|
288
|
+
let borderScript = '';
|
|
289
|
+
if (edges.includes('all')) {
|
|
290
|
+
borderScript = `
|
|
291
|
+
$range.Borders.LineStyle = ${borderStyle}
|
|
292
|
+
$range.Borders.Weight = ${borderWeight}`;
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
borderScript = edges.map(e => `$range.Borders(${edgeMap[e]}).LineStyle = ${borderStyle}
|
|
296
|
+
$range.Borders(${edgeMap[e]}).Weight = ${borderWeight}`).join('\n');
|
|
297
|
+
}
|
|
298
|
+
return this.executePowerShell(`
|
|
299
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
300
|
+
$workbook = $excel.ActiveWorkbook
|
|
301
|
+
${sheetScript}
|
|
302
|
+
$range = $sheet.Range('${range}')
|
|
303
|
+
${borderScript}
|
|
304
|
+
@{ success = $true; message = "Border set for ${range}" } | ConvertTo-Json -Compress
|
|
305
|
+
`);
|
|
306
|
+
}
|
|
307
|
+
async excelSetFill(range, color, sheet) {
|
|
308
|
+
const rgb = this.hexToRgb(color);
|
|
309
|
+
const colorValue = rgb ? rgb.r + rgb.g * 256 + rgb.b * 65536 : 0;
|
|
310
|
+
const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
|
|
311
|
+
return this.executePowerShell(`
|
|
312
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
313
|
+
$workbook = $excel.ActiveWorkbook
|
|
314
|
+
${sheetScript}
|
|
315
|
+
$sheet.Range('${range}').Interior.Color = ${colorValue}
|
|
316
|
+
@{ success = $true; message = "Fill color set for ${range}" } | ConvertTo-Json -Compress
|
|
317
|
+
`);
|
|
318
|
+
}
|
|
319
|
+
async excelSetNumberFormat(range, format, sheet) {
|
|
320
|
+
const escapedFormat = format.replace(/'/g, "''");
|
|
321
|
+
const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
|
|
322
|
+
return this.executePowerShell(`
|
|
323
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
324
|
+
$workbook = $excel.ActiveWorkbook
|
|
325
|
+
${sheetScript}
|
|
326
|
+
$sheet.Range('${range}').NumberFormat = '${escapedFormat}'
|
|
327
|
+
@{ success = $true; message = "Number format set for ${range}" } | ConvertTo-Json -Compress
|
|
328
|
+
`);
|
|
329
|
+
}
|
|
330
|
+
async excelAddSheet(name, position) {
|
|
331
|
+
const escapedName = name?.replace(/'/g, "''") || '';
|
|
332
|
+
let positionScript = '';
|
|
333
|
+
if (position === 'start') {
|
|
334
|
+
positionScript = ', [ref]$workbook.Sheets(1)';
|
|
335
|
+
}
|
|
336
|
+
else if (position === 'end') {
|
|
337
|
+
positionScript = ', , [ref]$workbook.Sheets($workbook.Sheets.Count)';
|
|
338
|
+
}
|
|
339
|
+
else if (position) {
|
|
340
|
+
positionScript = `, , [ref]$workbook.Sheets('${position.replace(/'/g, "''")}')`;
|
|
341
|
+
}
|
|
342
|
+
return this.executePowerShell(`
|
|
343
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
344
|
+
$workbook = $excel.ActiveWorkbook
|
|
345
|
+
$newSheet = $workbook.Sheets.Add(${positionScript})
|
|
346
|
+
${escapedName ? `$newSheet.Name = '${escapedName}'` : ''}
|
|
347
|
+
@{ success = $true; message = "Sheet added"; sheet_name = $newSheet.Name } | ConvertTo-Json -Compress
|
|
348
|
+
`);
|
|
349
|
+
}
|
|
350
|
+
async excelDeleteSheet(name) {
|
|
351
|
+
const escapedName = name.replace(/'/g, "''");
|
|
352
|
+
return this.executePowerShell(`
|
|
353
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
354
|
+
$workbook = $excel.ActiveWorkbook
|
|
355
|
+
$excel.DisplayAlerts = $false
|
|
356
|
+
$workbook.Sheets('${escapedName}').Delete()
|
|
357
|
+
$excel.DisplayAlerts = $true
|
|
358
|
+
@{ success = $true; message = "Sheet '${escapedName}' deleted" } | ConvertTo-Json -Compress
|
|
359
|
+
`);
|
|
360
|
+
}
|
|
361
|
+
async excelRenameSheet(oldName, newName) {
|
|
362
|
+
const escapedOld = oldName.replace(/'/g, "''");
|
|
363
|
+
const escapedNew = newName.replace(/'/g, "''");
|
|
364
|
+
return this.executePowerShell(`
|
|
365
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
366
|
+
$workbook = $excel.ActiveWorkbook
|
|
367
|
+
$workbook.Sheets('${escapedOld}').Name = '${escapedNew}'
|
|
368
|
+
@{ success = $true; message = "Sheet renamed from '${escapedOld}' to '${escapedNew}'" } | ConvertTo-Json -Compress
|
|
369
|
+
`);
|
|
370
|
+
}
|
|
371
|
+
async excelGetSheets() {
|
|
372
|
+
return this.executePowerShell(`
|
|
373
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
374
|
+
$workbook = $excel.ActiveWorkbook
|
|
375
|
+
$sheets = @()
|
|
376
|
+
foreach ($sheet in $workbook.Sheets) {
|
|
377
|
+
$sheets += $sheet.Name
|
|
378
|
+
}
|
|
379
|
+
@{ success = $true; sheets = $sheets; count = $sheets.Count } | ConvertTo-Json -Compress
|
|
380
|
+
`);
|
|
381
|
+
}
|
|
382
|
+
async excelSortRange(range, sortColumn, ascending = true, hasHeader = true, sheet) {
|
|
383
|
+
const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
|
|
384
|
+
const order = ascending ? 1 : 2;
|
|
385
|
+
const header = hasHeader ? 1 : 2;
|
|
386
|
+
return this.executePowerShell(`
|
|
387
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
388
|
+
$workbook = $excel.ActiveWorkbook
|
|
389
|
+
${sheetScript}
|
|
390
|
+
$range = $sheet.Range('${range}')
|
|
391
|
+
$sortKey = $sheet.Range('${sortColumn}1')
|
|
392
|
+
|
|
393
|
+
# Use Sort object for better compatibility
|
|
394
|
+
$sheet.Sort.SortFields.Clear()
|
|
395
|
+
$sheet.Sort.SortFields.Add($sortKey, 0, ${order})
|
|
396
|
+
$sheet.Sort.SetRange($range)
|
|
397
|
+
$sheet.Sort.Header = ${header}
|
|
398
|
+
$sheet.Sort.Apply()
|
|
399
|
+
|
|
400
|
+
@{ success = $true; message = "Range sorted by column ${sortColumn}" } | ConvertTo-Json -Compress
|
|
401
|
+
`);
|
|
402
|
+
}
|
|
403
|
+
async excelInsertRow(row, count = 1, sheet) {
|
|
404
|
+
const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
|
|
405
|
+
return this.executePowerShell(`
|
|
406
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
407
|
+
$workbook = $excel.ActiveWorkbook
|
|
408
|
+
${sheetScript}
|
|
409
|
+
for ($i = 0; $i -lt ${count}; $i++) {
|
|
410
|
+
$sheet.Rows(${row}).Insert()
|
|
411
|
+
}
|
|
412
|
+
@{ success = $true; message = "${count} row(s) inserted at row ${row}" } | ConvertTo-Json -Compress
|
|
413
|
+
`);
|
|
414
|
+
}
|
|
415
|
+
async excelDeleteRow(row, count = 1, sheet) {
|
|
416
|
+
const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
|
|
417
|
+
return this.executePowerShell(`
|
|
418
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
419
|
+
$workbook = $excel.ActiveWorkbook
|
|
420
|
+
${sheetScript}
|
|
421
|
+
$sheet.Rows("${row}:${row + count - 1}").Delete()
|
|
422
|
+
@{ success = $true; message = "${count} row(s) deleted starting at row ${row}" } | ConvertTo-Json -Compress
|
|
423
|
+
`);
|
|
424
|
+
}
|
|
425
|
+
async excelInsertColumn(column, count = 1, sheet) {
|
|
426
|
+
const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
|
|
427
|
+
return this.executePowerShell(`
|
|
428
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
429
|
+
$workbook = $excel.ActiveWorkbook
|
|
430
|
+
${sheetScript}
|
|
431
|
+
for ($i = 0; $i -lt ${count}; $i++) {
|
|
432
|
+
$sheet.Columns('${column}').Insert()
|
|
433
|
+
}
|
|
434
|
+
@{ success = $true; message = "${count} column(s) inserted at column ${column}" } | ConvertTo-Json -Compress
|
|
435
|
+
`);
|
|
436
|
+
}
|
|
437
|
+
async excelDeleteColumn(column, count = 1, sheet) {
|
|
438
|
+
const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
|
|
439
|
+
const startColNum = columnLetterToNumber(column.toUpperCase());
|
|
440
|
+
const endCol = columnNumberToLetter(startColNum + count - 1);
|
|
441
|
+
return this.executePowerShell(`
|
|
442
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
443
|
+
$workbook = $excel.ActiveWorkbook
|
|
444
|
+
${sheetScript}
|
|
445
|
+
$sheet.Columns("${column}:${endCol}").Delete()
|
|
446
|
+
@{ success = $true; message = "${count} column(s) deleted starting at column ${column}" } | ConvertTo-Json -Compress
|
|
447
|
+
`);
|
|
448
|
+
}
|
|
449
|
+
async excelFreezePanes(row, column, sheet) {
|
|
450
|
+
const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
|
|
451
|
+
const cellRef = `${column || 'A'}${row || 1}`;
|
|
452
|
+
return this.executePowerShell(`
|
|
453
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
454
|
+
$workbook = $excel.ActiveWorkbook
|
|
455
|
+
${sheetScript}
|
|
456
|
+
$sheet.Activate()
|
|
457
|
+
$sheet.Range('${cellRef}').Select()
|
|
458
|
+
$excel.ActiveWindow.FreezePanes = $true
|
|
459
|
+
@{ success = $true; message = "Panes frozen at ${cellRef}" } | ConvertTo-Json -Compress
|
|
460
|
+
`);
|
|
461
|
+
}
|
|
462
|
+
async excelAutoFilter(range, sheet) {
|
|
463
|
+
const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
|
|
464
|
+
return this.executePowerShell(`
|
|
465
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
466
|
+
$workbook = $excel.ActiveWorkbook
|
|
467
|
+
${sheetScript}
|
|
468
|
+
$sheet.Range('${range}').AutoFilter()
|
|
469
|
+
@{ success = $true; message = "AutoFilter applied to ${range}" } | ConvertTo-Json -Compress
|
|
470
|
+
`);
|
|
471
|
+
}
|
|
472
|
+
async excelScreenshot() {
|
|
473
|
+
const result = await this.executePowerShell(`
|
|
474
|
+
Add-Type -AssemblyName System.Windows.Forms
|
|
475
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
476
|
+
$sheet = $excel.ActiveWorkbook.ActiveSheet
|
|
477
|
+
|
|
478
|
+
# Get used range and copy as picture
|
|
479
|
+
$usedRange = $sheet.UsedRange
|
|
480
|
+
$usedRange.CopyPicture(1, 2) # xlScreen=1, xlBitmap=2
|
|
481
|
+
|
|
482
|
+
# Get image from clipboard
|
|
483
|
+
Start-Sleep -Milliseconds 500
|
|
484
|
+
$img = [System.Windows.Forms.Clipboard]::GetImage()
|
|
485
|
+
if ($img -eq $null) {
|
|
486
|
+
@{ success = $false; error = "Failed to capture screenshot" } | ConvertTo-Json -Compress
|
|
487
|
+
return
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
# Convert to base64
|
|
491
|
+
$ms = New-Object System.IO.MemoryStream
|
|
492
|
+
$img.Save($ms, [System.Drawing.Imaging.ImageFormat]::Png)
|
|
493
|
+
$bytes = $ms.ToArray()
|
|
494
|
+
$base64 = [Convert]::ToBase64String($bytes)
|
|
495
|
+
$ms.Dispose()
|
|
496
|
+
$img.Dispose()
|
|
497
|
+
|
|
498
|
+
@{
|
|
499
|
+
success = $true
|
|
500
|
+
image = $base64
|
|
501
|
+
format = "png"
|
|
502
|
+
encoding = "base64"
|
|
503
|
+
} | ConvertTo-Json -Compress
|
|
504
|
+
`);
|
|
505
|
+
return result;
|
|
506
|
+
}
|
|
507
|
+
async excelAddChart(dataRange, chartType, options) {
|
|
508
|
+
const chartTypeMap = {
|
|
509
|
+
column: 51,
|
|
510
|
+
bar: 57,
|
|
511
|
+
line: 4,
|
|
512
|
+
pie: 5,
|
|
513
|
+
area: 1,
|
|
514
|
+
scatter: -4169,
|
|
515
|
+
doughnut: -4120,
|
|
516
|
+
};
|
|
517
|
+
const xlChartType = chartTypeMap[chartType] ?? 51;
|
|
518
|
+
const escapedTitle = options?.title?.replace(/'/g, "''") || '';
|
|
519
|
+
const hasKorean = options?.title ? /[가-힣ㄱ-ㅎㅏ-ㅣ]/.test(options.title) : false;
|
|
520
|
+
const sheetScript = options?.sheet ?
|
|
521
|
+
`$sheet = $excel.ActiveWorkbook.Worksheets('${options.sheet.replace(/'/g, "''")}')` :
|
|
522
|
+
'$sheet = $excel.ActiveWorkbook.ActiveSheet';
|
|
523
|
+
const left = options?.left ?? 100;
|
|
524
|
+
const top = options?.top ?? 100;
|
|
525
|
+
const width = options?.width ?? 400;
|
|
526
|
+
const height = options?.height ?? 300;
|
|
527
|
+
const titleScript = escapedTitle ? `
|
|
528
|
+
$chart.HasTitle = $true
|
|
529
|
+
$chart.ChartTitle.Text = '${escapedTitle}'
|
|
530
|
+
${hasKorean ? "$chart.ChartTitle.Font.Name = 'Malgun Gothic'" : ''}` : '';
|
|
531
|
+
return this.executePowerShell(`
|
|
532
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
533
|
+
${sheetScript}
|
|
534
|
+
$range = $sheet.Range('${dataRange}')
|
|
535
|
+
$chartObj = $sheet.ChartObjects().Add(${left}, ${top}, ${width}, ${height})
|
|
536
|
+
$chart = $chartObj.Chart
|
|
537
|
+
$chart.SetSourceData($range)
|
|
538
|
+
$chart.ChartType = ${xlChartType}
|
|
539
|
+
${titleScript}
|
|
540
|
+
@{ success = $true; message = "Chart added"; chart_name = $chartObj.Name } | ConvertTo-Json -Compress
|
|
541
|
+
`);
|
|
542
|
+
}
|
|
543
|
+
async excelSetChartTitle(chartIndex, title, sheet) {
|
|
544
|
+
const escapedTitle = title.replace(/'/g, "''");
|
|
545
|
+
const hasKorean = /[가-힣ㄱ-ㅎㅏ-ㅣ]/.test(title);
|
|
546
|
+
const sheetScript = sheet ?
|
|
547
|
+
`$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
|
|
548
|
+
'$sheet = $excel.ActiveWorkbook.ActiveSheet';
|
|
549
|
+
return this.executePowerShell(`
|
|
550
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
551
|
+
${sheetScript}
|
|
552
|
+
$chartObj = $sheet.ChartObjects(${chartIndex})
|
|
553
|
+
$chart = $chartObj.Chart
|
|
554
|
+
$chart.HasTitle = $true
|
|
555
|
+
$chart.ChartTitle.Text = '${escapedTitle}'
|
|
556
|
+
${hasKorean ? "$chart.ChartTitle.Font.Name = 'Malgun Gothic'" : ''}
|
|
557
|
+
@{ success = $true; message = "Chart title set" } | ConvertTo-Json -Compress
|
|
558
|
+
`);
|
|
559
|
+
}
|
|
560
|
+
async excelDeleteChart(chartIndex, sheet) {
|
|
561
|
+
const sheetScript = sheet ?
|
|
562
|
+
`$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
|
|
563
|
+
'$sheet = $excel.ActiveWorkbook.ActiveSheet';
|
|
564
|
+
return this.executePowerShell(`
|
|
565
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
566
|
+
${sheetScript}
|
|
567
|
+
$sheet.ChartObjects(${chartIndex}).Delete()
|
|
568
|
+
@{ success = $true; message = "Chart deleted" } | ConvertTo-Json -Compress
|
|
569
|
+
`);
|
|
570
|
+
}
|
|
571
|
+
async excelAddConditionalFormat(range, formatType, options) {
|
|
572
|
+
const sheetScript = options?.sheet ?
|
|
573
|
+
`$sheet = $excel.ActiveWorkbook.Worksheets('${options.sheet.replace(/'/g, "''")}')` :
|
|
574
|
+
'$sheet = $excel.ActiveWorkbook.ActiveSheet';
|
|
575
|
+
const typeMap = {
|
|
576
|
+
cellValue: 1,
|
|
577
|
+
colorScale: 3,
|
|
578
|
+
dataBar: 4,
|
|
579
|
+
iconSet: 6,
|
|
580
|
+
duplicates: 8,
|
|
581
|
+
top10: 5,
|
|
582
|
+
};
|
|
583
|
+
const conditionType = typeMap[formatType] ?? 1;
|
|
584
|
+
const operatorMap = {
|
|
585
|
+
greater: 5,
|
|
586
|
+
less: 6,
|
|
587
|
+
equal: 3,
|
|
588
|
+
between: 1,
|
|
589
|
+
notBetween: 2,
|
|
590
|
+
};
|
|
591
|
+
const xlOperator = options?.operator ? operatorMap[options.operator] : 5;
|
|
592
|
+
let formatScript = '';
|
|
593
|
+
if (formatType === 'cellValue') {
|
|
594
|
+
const formula1 = typeof options?.value1 === 'string' ? `"${options.value1}"` : options?.value1 ?? 0;
|
|
595
|
+
const formula2 = options?.value2 !== undefined ?
|
|
596
|
+
(typeof options.value2 === 'string' ? `"${options.value2}"` : options.value2) : '';
|
|
597
|
+
formatScript = `
|
|
598
|
+
$fc = $range.FormatConditions.Add(${conditionType}, ${xlOperator}, ${formula1}${formula2 ? `, ${formula2}` : ''})`;
|
|
599
|
+
if (options?.fillColor) {
|
|
600
|
+
const rgb = this.hexToRgb(options.fillColor);
|
|
601
|
+
if (rgb) {
|
|
602
|
+
formatScript += `\n$fc.Interior.Color = ${rgb.r + rgb.g * 256 + rgb.b * 65536}`;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
if (options?.fontColor) {
|
|
606
|
+
const rgb = this.hexToRgb(options.fontColor);
|
|
607
|
+
if (rgb) {
|
|
608
|
+
formatScript += `\n$fc.Font.Color = ${rgb.r + rgb.g * 256 + rgb.b * 65536}`;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
else if (formatType === 'colorScale') {
|
|
613
|
+
formatScript = '$range.FormatConditions.AddColorScale(3)';
|
|
614
|
+
}
|
|
615
|
+
else if (formatType === 'dataBar') {
|
|
616
|
+
formatScript = '$range.FormatConditions.AddDataBar()';
|
|
617
|
+
}
|
|
618
|
+
else if (formatType === 'iconSet') {
|
|
619
|
+
formatScript = '$range.FormatConditions.AddIconSetCondition()';
|
|
620
|
+
}
|
|
621
|
+
else if (formatType === 'duplicates') {
|
|
622
|
+
formatScript = `$fc = $range.FormatConditions.AddUniqueValues()
|
|
623
|
+
$fc.DupeUnique = 1`;
|
|
624
|
+
if (options?.fillColor) {
|
|
625
|
+
const rgb = this.hexToRgb(options.fillColor);
|
|
626
|
+
if (rgb) {
|
|
627
|
+
formatScript += `\n$fc.Interior.Color = ${rgb.r + rgb.g * 256 + rgb.b * 65536}`;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
else if (formatType === 'top10') {
|
|
632
|
+
formatScript = `$fc = $range.FormatConditions.AddTop10()
|
|
633
|
+
$fc.TopBottom = 1
|
|
634
|
+
$fc.Rank = 10`;
|
|
635
|
+
if (options?.fillColor) {
|
|
636
|
+
const rgb = this.hexToRgb(options.fillColor);
|
|
637
|
+
if (rgb) {
|
|
638
|
+
formatScript += `\n$fc.Interior.Color = ${rgb.r + rgb.g * 256 + rgb.b * 65536}`;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
return this.executePowerShell(`
|
|
643
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
644
|
+
${sheetScript}
|
|
645
|
+
$range = $sheet.Range('${range}')
|
|
646
|
+
${formatScript}
|
|
647
|
+
@{ success = $true; message = "Conditional format added to ${range}" } | ConvertTo-Json -Compress
|
|
648
|
+
`);
|
|
649
|
+
}
|
|
650
|
+
async excelClearConditionalFormat(range, sheet) {
|
|
651
|
+
const sheetScript = sheet ?
|
|
652
|
+
`$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
|
|
653
|
+
'$sheet = $excel.ActiveWorkbook.ActiveSheet';
|
|
654
|
+
return this.executePowerShell(`
|
|
655
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
656
|
+
${sheetScript}
|
|
657
|
+
$sheet.Range('${range}').FormatConditions.Delete()
|
|
658
|
+
@{ success = $true; message = "Conditional formatting cleared from ${range}" } | ConvertTo-Json -Compress
|
|
659
|
+
`);
|
|
660
|
+
}
|
|
661
|
+
async excelSetDataValidation(range, validationType, options) {
|
|
662
|
+
const sheetScript = options?.sheet ?
|
|
663
|
+
`$sheet = $excel.ActiveWorkbook.Worksheets('${options.sheet.replace(/'/g, "''")}')` :
|
|
664
|
+
'$sheet = $excel.ActiveWorkbook.ActiveSheet';
|
|
665
|
+
const typeMap = {
|
|
666
|
+
list: 3,
|
|
667
|
+
whole: 1,
|
|
668
|
+
decimal: 2,
|
|
669
|
+
date: 4,
|
|
670
|
+
textLength: 6,
|
|
671
|
+
custom: 7,
|
|
672
|
+
};
|
|
673
|
+
const dvType = typeMap[validationType] ?? 3;
|
|
674
|
+
const operatorMap = {
|
|
675
|
+
between: 1,
|
|
676
|
+
notBetween: 2,
|
|
677
|
+
equal: 3,
|
|
678
|
+
notEqual: 4,
|
|
679
|
+
greater: 5,
|
|
680
|
+
less: 6,
|
|
681
|
+
greaterEqual: 7,
|
|
682
|
+
lessEqual: 8,
|
|
683
|
+
};
|
|
684
|
+
const xlOperator = options.operator ? operatorMap[options.operator] : 1;
|
|
685
|
+
const formula1 = options.formula1?.replace(/'/g, "''") || '';
|
|
686
|
+
const formula2 = options.formula2?.replace(/'/g, "''") || '';
|
|
687
|
+
const additionalSettings = [];
|
|
688
|
+
if (options.showInputMessage !== false && (options.inputTitle || options.inputMessage)) {
|
|
689
|
+
additionalSettings.push('$validation.ShowInput = $true');
|
|
690
|
+
if (options.inputTitle)
|
|
691
|
+
additionalSettings.push(`$validation.InputTitle = '${options.inputTitle.replace(/'/g, "''")}'`);
|
|
692
|
+
if (options.inputMessage)
|
|
693
|
+
additionalSettings.push(`$validation.InputMessage = '${options.inputMessage.replace(/'/g, "''")}'`);
|
|
694
|
+
}
|
|
695
|
+
if (options.showErrorMessage !== false && (options.errorTitle || options.errorMessage)) {
|
|
696
|
+
additionalSettings.push('$validation.ShowError = $true');
|
|
697
|
+
if (options.errorTitle)
|
|
698
|
+
additionalSettings.push(`$validation.ErrorTitle = '${options.errorTitle.replace(/'/g, "''")}'`);
|
|
699
|
+
if (options.errorMessage)
|
|
700
|
+
additionalSettings.push(`$validation.ErrorMessage = '${options.errorMessage.replace(/'/g, "''")}'`);
|
|
701
|
+
}
|
|
702
|
+
const validationParams = validationType === 'list'
|
|
703
|
+
? `${dvType}, 1, 1, '${formula1}'`
|
|
704
|
+
: `${dvType}, 1, ${xlOperator}, '${formula1}'${formula2 ? `, '${formula2}'` : ''}`;
|
|
705
|
+
return this.executePowerShell(`
|
|
706
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
707
|
+
${sheetScript}
|
|
708
|
+
$range = $sheet.Range('${range}')
|
|
709
|
+
$range.Validation.Delete()
|
|
710
|
+
$range.Validation.Add(${validationParams})
|
|
711
|
+
$validation = $range.Validation
|
|
712
|
+
${additionalSettings.join('\n')}
|
|
713
|
+
@{ success = $true; message = "Data validation set on ${range}" } | ConvertTo-Json -Compress
|
|
714
|
+
`);
|
|
715
|
+
}
|
|
716
|
+
async excelClearDataValidation(range, sheet) {
|
|
717
|
+
const sheetScript = sheet ?
|
|
718
|
+
`$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
|
|
719
|
+
'$sheet = $excel.ActiveWorkbook.ActiveSheet';
|
|
720
|
+
return this.executePowerShell(`
|
|
721
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
722
|
+
${sheetScript}
|
|
723
|
+
$sheet.Range('${range}').Validation.Delete()
|
|
724
|
+
@{ success = $true; message = "Data validation cleared from ${range}" } | ConvertTo-Json -Compress
|
|
725
|
+
`);
|
|
726
|
+
}
|
|
727
|
+
async excelCreateNamedRange(name, range, sheet) {
|
|
728
|
+
const escapedName = name.replace(/'/g, "''");
|
|
729
|
+
const sheetScript = sheet ?
|
|
730
|
+
`$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
|
|
731
|
+
'$sheet = $excel.ActiveWorkbook.ActiveSheet';
|
|
732
|
+
return this.executePowerShell(`
|
|
733
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
734
|
+
$workbook = $excel.ActiveWorkbook
|
|
735
|
+
${sheetScript}
|
|
736
|
+
$range = $sheet.Range('${range}')
|
|
737
|
+
$workbook.Names.Add('${escapedName}', $range)
|
|
738
|
+
@{ success = $true; message = "Named range '${escapedName}' created" } | ConvertTo-Json -Compress
|
|
739
|
+
`);
|
|
740
|
+
}
|
|
741
|
+
async excelGetNamedRanges() {
|
|
742
|
+
return this.executePowerShell(`
|
|
743
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
744
|
+
$workbook = $excel.ActiveWorkbook
|
|
745
|
+
$names = @()
|
|
746
|
+
foreach ($n in $workbook.Names) {
|
|
747
|
+
$names += @{
|
|
748
|
+
name = $n.Name
|
|
749
|
+
refersTo = $n.RefersTo
|
|
750
|
+
value = $n.Value
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
@{ success = $true; named_ranges = $names } | ConvertTo-Json -Compress -Depth 5
|
|
754
|
+
`);
|
|
755
|
+
}
|
|
756
|
+
async excelDeleteNamedRange(name) {
|
|
757
|
+
const escapedName = name.replace(/'/g, "''");
|
|
758
|
+
return this.executePowerShell(`
|
|
759
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
760
|
+
$workbook = $excel.ActiveWorkbook
|
|
761
|
+
$workbook.Names('${escapedName}').Delete()
|
|
762
|
+
@{ success = $true; message = "Named range '${escapedName}' deleted" } | ConvertTo-Json -Compress
|
|
763
|
+
`);
|
|
764
|
+
}
|
|
765
|
+
async excelCopyRange(range, sheet) {
|
|
766
|
+
const sheetScript = sheet ?
|
|
767
|
+
`$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
|
|
768
|
+
'$sheet = $excel.ActiveWorkbook.ActiveSheet';
|
|
769
|
+
return this.executePowerShell(`
|
|
770
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
771
|
+
${sheetScript}
|
|
772
|
+
$sheet.Range('${range}').Copy()
|
|
773
|
+
@{ success = $true; message = "Range ${range} copied to clipboard" } | ConvertTo-Json -Compress
|
|
774
|
+
`);
|
|
775
|
+
}
|
|
776
|
+
async excelPasteRange(destination, sheet) {
|
|
777
|
+
const sheetScript = sheet ?
|
|
778
|
+
`$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
|
|
779
|
+
'$sheet = $excel.ActiveWorkbook.ActiveSheet';
|
|
780
|
+
return this.executePowerShell(`
|
|
781
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
782
|
+
${sheetScript}
|
|
783
|
+
$sheet.Range('${destination}').Select()
|
|
784
|
+
$sheet.Paste()
|
|
785
|
+
@{ success = $true; message = "Pasted to ${destination}" } | ConvertTo-Json -Compress
|
|
786
|
+
`);
|
|
787
|
+
}
|
|
788
|
+
async excelClearRange(range, clearType = 'all', sheet) {
|
|
789
|
+
const sheetScript = sheet ?
|
|
790
|
+
`$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
|
|
791
|
+
'$sheet = $excel.ActiveWorkbook.ActiveSheet';
|
|
792
|
+
const clearMethod = {
|
|
793
|
+
all: 'Clear()',
|
|
794
|
+
contents: 'ClearContents()',
|
|
795
|
+
formats: 'ClearFormats()',
|
|
796
|
+
comments: 'ClearComments()',
|
|
797
|
+
}[clearType];
|
|
798
|
+
return this.executePowerShell(`
|
|
799
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
800
|
+
${sheetScript}
|
|
801
|
+
$sheet.Range('${range}').${clearMethod}
|
|
802
|
+
@{ success = $true; message = "Range ${range} cleared (${clearType})" } | ConvertTo-Json -Compress
|
|
803
|
+
`);
|
|
804
|
+
}
|
|
805
|
+
async excelHideColumn(column, sheet) {
|
|
806
|
+
const sheetScript = sheet ?
|
|
807
|
+
`$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
|
|
808
|
+
'$sheet = $excel.ActiveWorkbook.ActiveSheet';
|
|
809
|
+
return this.executePowerShell(`
|
|
810
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
811
|
+
${sheetScript}
|
|
812
|
+
$sheet.Columns('${column}').Hidden = $true
|
|
813
|
+
@{ success = $true; message = "Column ${column} hidden" } | ConvertTo-Json -Compress
|
|
814
|
+
`);
|
|
815
|
+
}
|
|
816
|
+
async excelShowColumn(column, sheet) {
|
|
817
|
+
const sheetScript = sheet ?
|
|
818
|
+
`$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
|
|
819
|
+
'$sheet = $excel.ActiveWorkbook.ActiveSheet';
|
|
820
|
+
return this.executePowerShell(`
|
|
821
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
822
|
+
${sheetScript}
|
|
823
|
+
$sheet.Columns('${column}').Hidden = $false
|
|
824
|
+
@{ success = $true; message = "Column ${column} shown" } | ConvertTo-Json -Compress
|
|
825
|
+
`);
|
|
826
|
+
}
|
|
827
|
+
async excelHideRow(row, sheet) {
|
|
828
|
+
const sheetScript = sheet ?
|
|
829
|
+
`$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
|
|
830
|
+
'$sheet = $excel.ActiveWorkbook.ActiveSheet';
|
|
831
|
+
return this.executePowerShell(`
|
|
832
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
833
|
+
${sheetScript}
|
|
834
|
+
$sheet.Rows(${row}).Hidden = $true
|
|
835
|
+
@{ success = $true; message = "Row ${row} hidden" } | ConvertTo-Json -Compress
|
|
836
|
+
`);
|
|
837
|
+
}
|
|
838
|
+
async excelShowRow(row, sheet) {
|
|
839
|
+
const sheetScript = sheet ?
|
|
840
|
+
`$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
|
|
841
|
+
'$sheet = $excel.ActiveWorkbook.ActiveSheet';
|
|
842
|
+
return this.executePowerShell(`
|
|
843
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
844
|
+
${sheetScript}
|
|
845
|
+
$sheet.Rows(${row}).Hidden = $false
|
|
846
|
+
@{ success = $true; message = "Row ${row} shown" } | ConvertTo-Json -Compress
|
|
847
|
+
`);
|
|
848
|
+
}
|
|
849
|
+
async excelAddImage(imagePath, cell, options) {
|
|
850
|
+
const windowsPath = this.toWindowsPath(imagePath).replace(/'/g, "''");
|
|
851
|
+
const sheetScript = options?.sheet ?
|
|
852
|
+
`$sheet = $excel.ActiveWorkbook.Worksheets('${options.sheet.replace(/'/g, "''")}')` :
|
|
853
|
+
'$sheet = $excel.ActiveWorkbook.ActiveSheet';
|
|
854
|
+
const sizeScript = [];
|
|
855
|
+
if (options?.width)
|
|
856
|
+
sizeScript.push(`$pic.Width = ${options.width}`);
|
|
857
|
+
if (options?.height)
|
|
858
|
+
sizeScript.push(`$pic.Height = ${options.height}`);
|
|
859
|
+
return this.executePowerShell(`
|
|
860
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
861
|
+
${sheetScript}
|
|
862
|
+
$cell = $sheet.Range('${cell}')
|
|
863
|
+
$pic = $sheet.Shapes.AddPicture('${windowsPath}', 0, -1, $cell.Left, $cell.Top, -1, -1)
|
|
864
|
+
${sizeScript.join('\n')}
|
|
865
|
+
@{ success = $true; message = "Image added at ${cell}" } | ConvertTo-Json -Compress
|
|
866
|
+
`);
|
|
867
|
+
}
|
|
868
|
+
async excelAddHyperlink(cell, url, displayText, sheet) {
|
|
869
|
+
const escapedUrl = url.replace(/'/g, "''");
|
|
870
|
+
const escapedText = displayText?.replace(/'/g, "''") || url;
|
|
871
|
+
const sheetScript = sheet ?
|
|
872
|
+
`$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
|
|
873
|
+
'$sheet = $excel.ActiveWorkbook.ActiveSheet';
|
|
874
|
+
return this.executePowerShell(`
|
|
875
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
876
|
+
${sheetScript}
|
|
877
|
+
$range = $sheet.Range('${cell}')
|
|
878
|
+
$sheet.Hyperlinks.Add($range, '${escapedUrl}', '', '', '${escapedText}')
|
|
879
|
+
@{ success = $true; message = "Hyperlink added to ${cell}" } | ConvertTo-Json -Compress
|
|
880
|
+
`);
|
|
881
|
+
}
|
|
882
|
+
async excelExportPDF(outputPath, sheet) {
|
|
883
|
+
const windowsPath = this.toWindowsPath(outputPath).replace(/'/g, "''");
|
|
884
|
+
const sheetScript = sheet ?
|
|
885
|
+
`$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')
|
|
886
|
+
$sheet.ExportAsFixedFormat(0, '${windowsPath}')` :
|
|
887
|
+
`$excel.ActiveWorkbook.ExportAsFixedFormat(0, '${windowsPath}')`;
|
|
888
|
+
return this.executePowerShell(`
|
|
889
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
890
|
+
${sheetScript}
|
|
891
|
+
@{ success = $true; message = "Exported to PDF"; path = '${windowsPath}' } | ConvertTo-Json -Compress
|
|
892
|
+
`);
|
|
893
|
+
}
|
|
894
|
+
async excelPrint(copies = 1, sheet) {
|
|
895
|
+
const sheetScript = sheet ?
|
|
896
|
+
`$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')
|
|
897
|
+
$sheet.PrintOut(1, 9999, ${copies})` :
|
|
898
|
+
`$excel.ActiveWorkbook.PrintOut(1, 9999, ${copies})`;
|
|
899
|
+
return this.executePowerShell(`
|
|
900
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
901
|
+
${sheetScript}
|
|
902
|
+
@{ success = $true; message = "Print job sent (${copies} copies)" } | ConvertTo-Json -Compress
|
|
903
|
+
`);
|
|
904
|
+
}
|
|
905
|
+
async excelAddComment(cell, text, _author, sheet) {
|
|
906
|
+
const escapedText = text.replace(/'/g, "''");
|
|
907
|
+
const sheetScript = sheet ?
|
|
908
|
+
`$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
|
|
909
|
+
'$sheet = $excel.ActiveWorkbook.ActiveSheet';
|
|
910
|
+
return this.executePowerShell(`
|
|
911
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
912
|
+
${sheetScript}
|
|
913
|
+
$cell = $sheet.Range('${cell}')
|
|
914
|
+
if ($cell.Comment -ne $null) { $cell.Comment.Delete() }
|
|
915
|
+
$comment = $cell.AddComment('${escapedText}')
|
|
916
|
+
$comment.Visible = $false
|
|
917
|
+
@{ success = $true; message = "Comment added to ${cell}" } | ConvertTo-Json -Compress
|
|
918
|
+
`);
|
|
919
|
+
}
|
|
920
|
+
async excelGetComment(cell, sheet) {
|
|
921
|
+
const sheetScript = sheet ?
|
|
922
|
+
`$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
|
|
923
|
+
'$sheet = $excel.ActiveWorkbook.ActiveSheet';
|
|
924
|
+
return this.executePowerShell(`
|
|
925
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
926
|
+
${sheetScript}
|
|
927
|
+
$cell = $sheet.Range('${cell}')
|
|
928
|
+
if ($cell.Comment -ne $null) {
|
|
929
|
+
@{ success = $true; has_comment = $true; text = $cell.Comment.Text() } | ConvertTo-Json -Compress
|
|
930
|
+
} else {
|
|
931
|
+
@{ success = $true; has_comment = $false } | ConvertTo-Json -Compress
|
|
932
|
+
}
|
|
933
|
+
`);
|
|
934
|
+
}
|
|
935
|
+
async excelDeleteComment(cell, sheet) {
|
|
936
|
+
const sheetScript = sheet ?
|
|
937
|
+
`$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
|
|
938
|
+
'$sheet = $excel.ActiveWorkbook.ActiveSheet';
|
|
939
|
+
return this.executePowerShell(`
|
|
940
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
941
|
+
${sheetScript}
|
|
942
|
+
$cell = $sheet.Range('${cell}')
|
|
943
|
+
if ($cell.Comment -ne $null) {
|
|
944
|
+
$cell.Comment.Delete()
|
|
945
|
+
@{ success = $true; message = "Comment deleted from ${cell}" } | ConvertTo-Json -Compress
|
|
946
|
+
} else {
|
|
947
|
+
@{ success = $false; error = "No comment found at ${cell}" } | ConvertTo-Json -Compress
|
|
948
|
+
}
|
|
949
|
+
`);
|
|
950
|
+
}
|
|
951
|
+
async excelProtectSheet(password, sheet) {
|
|
952
|
+
const escapedPassword = password?.replace(/'/g, "''") || '';
|
|
953
|
+
const sheetScript = sheet ?
|
|
954
|
+
`$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
|
|
955
|
+
'$sheet = $excel.ActiveWorkbook.ActiveSheet';
|
|
956
|
+
return this.executePowerShell(`
|
|
957
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
958
|
+
${sheetScript}
|
|
959
|
+
$sheet.Protect('${escapedPassword}')
|
|
960
|
+
@{ success = $true; message = "Sheet protected" } | ConvertTo-Json -Compress
|
|
961
|
+
`);
|
|
962
|
+
}
|
|
963
|
+
async excelUnprotectSheet(password, sheet) {
|
|
964
|
+
const escapedPassword = password?.replace(/'/g, "''") || '';
|
|
965
|
+
const sheetScript = sheet ?
|
|
966
|
+
`$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
|
|
967
|
+
'$sheet = $excel.ActiveWorkbook.ActiveSheet';
|
|
968
|
+
return this.executePowerShell(`
|
|
969
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
970
|
+
${sheetScript}
|
|
971
|
+
$sheet.Unprotect('${escapedPassword}')
|
|
972
|
+
@{ success = $true; message = "Sheet unprotected" } | ConvertTo-Json -Compress
|
|
973
|
+
`);
|
|
974
|
+
}
|
|
975
|
+
async excelUnmergeCells(range, sheet) {
|
|
976
|
+
const sheetScript = sheet ?
|
|
977
|
+
`$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
|
|
978
|
+
'$sheet = $excel.ActiveWorkbook.ActiveSheet';
|
|
979
|
+
return this.executePowerShell(`
|
|
980
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
981
|
+
${sheetScript}
|
|
982
|
+
$sheet.Range('${range}').UnMerge()
|
|
983
|
+
@{ success = $true; message = "Cells unmerged: ${range}" } | ConvertTo-Json -Compress
|
|
984
|
+
`);
|
|
985
|
+
}
|
|
986
|
+
async excelSelectSheet(name) {
|
|
987
|
+
const escapedName = name.replace(/'/g, "''");
|
|
988
|
+
return this.executePowerShell(`
|
|
989
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
990
|
+
$excel.ActiveWorkbook.Worksheets('${escapedName}').Activate()
|
|
991
|
+
@{ success = $true; message = "Sheet '${escapedName}' activated" } | ConvertTo-Json -Compress
|
|
992
|
+
`);
|
|
993
|
+
}
|
|
994
|
+
async excelFindReplace(find, replace, options) {
|
|
995
|
+
const escapedFind = find.replace(/'/g, "''");
|
|
996
|
+
const escapedReplace = replace.replace(/'/g, "''");
|
|
997
|
+
const sheetScript = options?.sheet ?
|
|
998
|
+
`$sheet = $excel.ActiveWorkbook.Worksheets('${options.sheet.replace(/'/g, "''")}')` :
|
|
999
|
+
'$sheet = $excel.ActiveWorkbook.ActiveSheet';
|
|
1000
|
+
const rangeScript = options?.range ?
|
|
1001
|
+
`$range = $sheet.Range('${options.range}')` :
|
|
1002
|
+
'$range = $sheet.UsedRange';
|
|
1003
|
+
const matchCase = options?.matchCase ? '$true' : '$false';
|
|
1004
|
+
const lookAt = options?.matchEntireCell ? '1' : '2';
|
|
1005
|
+
return this.executePowerShell(`
|
|
1006
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
1007
|
+
${sheetScript}
|
|
1008
|
+
${rangeScript}
|
|
1009
|
+
$replaced = $range.Replace('${escapedFind}', '${escapedReplace}', ${lookAt}, 1, ${matchCase})
|
|
1010
|
+
@{ success = $true; message = "Find and replace completed" } | ConvertTo-Json -Compress
|
|
1011
|
+
`);
|
|
1012
|
+
}
|
|
1013
|
+
async excelGroupRows(startRow, endRow, sheet) {
|
|
1014
|
+
const sheetScript = sheet ?
|
|
1015
|
+
`$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
|
|
1016
|
+
'$sheet = $excel.ActiveWorkbook.ActiveSheet';
|
|
1017
|
+
return this.executePowerShell(`
|
|
1018
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
1019
|
+
${sheetScript}
|
|
1020
|
+
$sheet.Rows("${startRow}:${endRow}").Group()
|
|
1021
|
+
@{ success = $true; message = "Rows ${startRow}-${endRow} grouped" } | ConvertTo-Json -Compress
|
|
1022
|
+
`);
|
|
1023
|
+
}
|
|
1024
|
+
async excelUngroupRows(startRow, endRow, sheet) {
|
|
1025
|
+
const sheetScript = sheet ?
|
|
1026
|
+
`$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
|
|
1027
|
+
'$sheet = $excel.ActiveWorkbook.ActiveSheet';
|
|
1028
|
+
return this.executePowerShell(`
|
|
1029
|
+
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
|
|
1030
|
+
${sheetScript}
|
|
1031
|
+
$sheet.Rows("${startRow}:${endRow}").Ungroup()
|
|
1032
|
+
@{ success = $true; message = "Rows ${startRow}-${endRow} ungrouped" } | ConvertTo-Json -Compress
|
|
1033
|
+
`);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
export const excelClient = new ExcelClient();
|
|
1037
|
+
//# sourceMappingURL=excel-client.js.map
|