Loading...
Loading...
Compare original and translation side by side
| Task | Method | Guide |
|---|---|---|
| READ — analyze existing data | | |
| CREATE — new xlsx from scratch | XML template | |
| EDIT — modify existing xlsx | XML unpack→edit→pack | |
| FIX — repair broken formulas in existing xlsx | XML unpack→fix | |
| VALIDATE — check formulas | | |
| 任务 | 方法 | 指南 |
|---|---|---|
| 读取 — 分析现有数据 | | |
| 创建 — 从零开始新建xlsx文件 | XML模板 | |
| 编辑 — 修改现有xlsx文件 | XML解包→编辑→打包 | |
| 修复 — 修复现有xlsx文件中的损坏公式 | XML解包→修复 | |
| 验证 — 检查公式 | | |
references/read-analyze.mdreferences/read-analyze.mdxlsx_reader.pyf'{v:.2f}'1287512875.00df['Revenue'].sum()xlsx_reader.pyf'{v:.2f}'12875.0012875df['Revenue'].sum()references/create.mdreferences/format.mdreferences/create.mdreferences/format.mdtemplates/minimal_xlsx/xlsx_pack.py<f>SUM(B2:B9)</f>format.mdtemplates/minimal_xlsx/xlsx_pack.py<f>SUM(B2:B9)</f>format.mdreferences/edit.mdreferences/edit.mdWorkbook()xlsx_reader.pypandasWorkbook()python3 SKILL_DIR/scripts/xlsx_unpack.py input.xlsx /tmp/xlsx_work/Workbook()xlsx_reader.pypandasWorkbook()python3 SKILL_DIR/scripts/xlsx_unpack.py input.xlsx /tmp/xlsx_work/
**Add a column** (formulas, numfmt, styles auto-copied from adjacent column):
```bash
python3 SKILL_DIR/scripts/xlsx_unpack.py input.xlsx /tmp/xlsx_work/
python3 SKILL_DIR/scripts/xlsx_add_column.py /tmp/xlsx_work/ --col G \
--sheet "Sheet1" --header "% of Total" \
--formula '=F{row}/$F$10' --formula-rows 2:9 \
--total-row 10 --total-formula '=SUM(G2:G9)' --numfmt '0.0%' \
--border-row 10 --border-style medium
python3 SKILL_DIR/scripts/xlsx_pack.py /tmp/xlsx_work/ output.xlsx--border-rowpython3 SKILL_DIR/scripts/xlsx_unpack.py input.xlsx /tmp/xlsx_work/
**添加列**(公式、数字格式、样式自动从相邻列复制):
```bash
python3 SKILL_DIR/scripts/xlsx_unpack.py input.xlsx /tmp/xlsx_work/
python3 SKILL_DIR/scripts/xlsx_add_column.py /tmp/xlsx_work/ --col G \
--sheet "Sheet1" --header "占比" \
--formula '=F{row}/$F$10' --formula-rows 2:9 \
--total-row 10 --total-formula '=SUM(G2:G9)' --numfmt '0.0%' \
--border-row 10 --border-style medium
python3 SKILL_DIR/scripts/xlsx_pack.py /tmp/xlsx_work/ output.xlsx--border-rowpython3 SKILL_DIR/scripts/xlsx_unpack.py input.xlsx /tmp/xlsx_work/**Row lookup rule**: When the task says "after row N (Label)", always find the row by searching for "Label" in the worksheet XML (`grep -n "Label" /tmp/xlsx_work/xl/worksheets/sheet*.xml` or check sharedStrings.xml). Use the actual row number + 1 for `--at`. Do NOT call `xlsx_shift_rows.py` separately — `xlsx_insert_row.py` calls it internally.
**Apply row-wide borders** (e.g. accounting line on a TOTAL row):
After running helper scripts, apply borders to ALL cells in the target row, not just newly added cells. In `xl/styles.xml`, append a new `<border>` with the desired style, then append a new `<xf>` in `<cellXfs>` that clones each cell's existing `<xf>` but sets the new `borderId`. Apply the new style index to every `<c>` in the row via the `s` attribute:
```xml
<!-- In xl/styles.xml, append to <borders>: -->
<border>
<left/><right/><top style="medium"/><bottom/><diagonal/>
</border>
<!-- Then append to <cellXfs> an xf clone with the new borderId for each existing style -->python3 SKILL_DIR/scripts/xlsx_unpack.py input.xlsx /tmp/xlsx_work/**行查找规则**:当任务要求“在第N行(标签)之后插入行”时,务必在工作表XML中搜索“标签”文本(使用`grep -n "Label" /tmp/xlsx_work/xl/worksheets/sheet*.xml`或查看sharedStrings.xml)。使用实际行号+1作为`--at`参数的值。切勿单独调用`xlsx_shift_rows.py`——`xlsx_insert_row.py`会在内部调用它。
**为整行添加边框**(例如在总计行添加会计风格线条):
运行辅助脚本后,为目标行的所有单元格添加边框,而不仅仅是新增单元格。在`xl/styles.xml`中,添加一个新的`<border>`元素设置所需样式,然后在`<cellXfs>`中添加一个新的`<xf>`元素,克隆每个单元格现有的`<xf>`但设置新的`borderId`。通过`s`属性将新样式索引应用到该行的每个`<c>`元素:
```xml
<!-- 在xl/styles.xml的<borders>中添加: -->
<border>
<left/><right/><top style="medium"/><bottom/><diagonal/>
</border>
<!-- 然后在<cellXfs>中为每个现有样式添加带有新borderId的xf克隆 -->python3 SKILL_DIR/scripts/xlsx_unpack.py input.xlsx /tmp/xlsx_work/undefinedundefinedreferences/fix.mdreferences/fix.md<f><f>references/validate.mdreferences/validate.mdformula_check.pylibreoffice_recalc.pyformula_check.pylibreoffice_recalc.py| Cell Role | Font Color | Hex Code |
|---|---|---|
| Hard-coded input / assumption | Blue | |
| Formula / computed result | Black | |
| Cross-sheet reference formula | Green | |
| 单元格角色 | 字体颜色 | 十六进制代码 |
|---|---|---|
| 硬编码输入/假设值 | 蓝色 | |
| 公式/计算结果 | 黑色 | |
| 跨工作表引用公式 | 绿色 | |
xlsx_pack.pyformula_check.pyxlsx_pack.pyformula_check.pypython3 SKILL_DIR/scripts/xlsx_reader.py input.xlsx # structure discovery
python3 SKILL_DIR/scripts/formula_check.py file.xlsx --json # formula validation
python3 SKILL_DIR/scripts/formula_check.py file.xlsx --report # standardized report
python3 SKILL_DIR/scripts/xlsx_unpack.py in.xlsx /tmp/work/ # unpack for XML editing
python3 SKILL_DIR/scripts/xlsx_pack.py /tmp/work/ out.xlsx # repack after editing
python3 SKILL_DIR/scripts/xlsx_shift_rows.py /tmp/work/ insert 5 1 # shift rows for insertion
python3 SKILL_DIR/scripts/xlsx_add_column.py /tmp/work/ --col G ... # add column with formulas
python3 SKILL_DIR/scripts/xlsx_insert_row.py /tmp/work/ --at 6 ... # insert row with datapython3 SKILL_DIR/scripts/xlsx_reader.py input.xlsx # 结构识别
python3 SKILL_DIR/scripts/formula_check.py file.xlsx --json # 公式验证
python3 SKILL_DIR/scripts/formula_check.py file.xlsx --report # 标准化报告
python3 SKILL_DIR/scripts/xlsx_unpack.py in.xlsx /tmp/work/ # 解包以进行XML编辑
python3 SKILL_DIR/scripts/xlsx_pack.py /tmp/work/ out.xlsx # 编辑后重新打包
python3 SKILL_DIR/scripts/xlsx_shift_rows.py /tmp/work/ insert 5 1 # 为插入行移动现有行
python3 SKILL_DIR/scripts/xlsx_add_column.py /tmp/work/ --col G ... # 添加带公式的列
python3 SKILL_DIR/scripts/xlsx_insert_row.py /tmp/work/ --at 6 ... # 插入带数据的行