Excel Translator Skill
Overview
This skill translates the text content of an Excel file (.xlsx) from English to Chinese using openpyxl. The Chinese translation is placed directly below the original English text in the same cell, separated by a newline — no new rows or columns are inserted. Original formatting (merged cells, fonts, colors, images) is preserved.
Workflow
- 1. Identify the input
.xlsx file path from the user. - Run
scripts/translate.py from the shell. - Deliver the output file to the user as an attachment.
Running the Script
CODEBLOCK0
The output file is saved automatically with a _translated suffix in the same directory.
Custom output path:
CODEBLOCK1
Environment Variables
The script reads API credentials from environment variables. These are pre-configured in the Manus sandbox:
- -
OPENAI_API_KEY — API key for the translation model. - INLINECODE5 — Base URL for the API endpoint (defaults to
https://api.openai.com/v1).
Bundled Resources
- -
scripts/translate.py — Core translation script. Scans all sheets, translates English text cells concurrently via OpenAI API, writes "English\nChinese" back into the same cell with wrap_text=True, and saves the result.
Excel 翻译技能
概述
该技能使用 openpyxl 将 Excel 文件(.xlsx)中的文本内容从英文翻译为中文。中文翻译直接放置在原始英文文本的下方同一单元格内,以换行符分隔——不插入新行或新列。原始格式(合并单元格、字体、颜色、图片)保持不变。
工作流程
- 1. 从用户处识别输入的 .xlsx 文件路径。
- 通过 shell 运行 scripts/translate.py。
- 将输出文件作为附件交付给用户。
运行脚本
bash
python3.11 /home/ubuntu/skills/excel-translator/scripts/translate.py /path/to/input.xlsx
输出文件会自动保存在同一目录下,文件名添加 _translated 后缀。
自定义输出路径:
bash
python3.11 /home/ubuntu/skills/excel-translator/scripts/translate.py /path/to/input.xlsx -o /path/to/output.xlsx
环境变量
脚本从环境变量中读取 API 凭证。这些已在 Manus 沙箱中预配置:
- - OPENAIAPIKEY — 翻译模型的 API 密钥。
- OPENAIBASEURL — API 端点的基础 URL(默认为 https://api.openai.com/v1)。
捆绑资源
- - scripts/translate.py — 核心翻译脚本。扫描所有工作表,通过 OpenAI API 并发翻译英文文本单元格,将 英文\n中文 写回同一单元格(设置 wrap_text=True),并保存结果。