技能版本 1.0.0

docx

Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments,

价格

免费

  • 安装:免费

在组织开通时一次性收取;再次读取清单或下载不重复收费。

以上为公开标价。你的组织可能有协议价,以控制台显示的价格为准。

如何使用

  1. 为组织安装

    开通即安装:组织固定使用开通时的版本(当前为 1.0.0)。升级到新版本需要取消后重新开通。

  2. 创建凭证

    客户端使用组织凭证读取;绑定到数字人后,数字人使用绑定凭证按需加载。请求中携带:

    Authorization: Bearer $ZGI_MARKET_KEY

  3. 读取清单与安装包

    清单列出版本、文件和校验值;安装包是一个 zip 文件。

    读取清单
    curl "https://market-api.zgi.im/v1/market/skills/docx/manifest" \
      -H "Authorization: Bearer $ZGI_MARKET_KEY"
    下载安装包
    curl "https://market-api.zgi.im/v1/market/skills/docx/package" \
      -H "Authorization: Bearer $ZGI_MARKET_KEY" \
      -o docx.zip

    读取清单和下载安装包不计入用量。下载后请用响应头中的 SHA-256 校验文件。

技能说明

名称
docx
说明
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.
会运行代码Python

技能包内含脚本文件,加载技能的运行时可能会执行它们,安装前请先阅读。

SKILL.md 节选

# DOCX creation, editing, and analysis

## Overview

A .docx file is a ZIP archive containing XML files.

## Quick Reference

| Task | Approach |
|------|----------|
| Read/analyze content | `pandoc` or unpack for raw XML |
| Create new document | Use `docx-js` - see Creating New Documents below |
| Edit existing document | Unpack → edit XML → repack - see Editing Existing Documents below |

### Converting .doc to .docx

Legacy `.doc` files must be converted before editing:

```bash
python scripts/office/soffice.py --headless --convert-to docx document.doc
```

### Reading Content

```bash
# Text extraction with tracked changes
pandoc --track-changes=all document.docx -o output.md

# Raw XML access
python scripts/office/unpack.py document.docx unpacked/
```

### Converting to Images

```bash
python scripts/office/soffice.py --headless --convert-to pdf document.docx
pdftoppm -jpeg -r 150 document.pdf page
```

### Accepting Tracked Changes

To produce a clean document with all tracked changes accepted (requires LibreOffice):

```bash
python scripts/accept_changes.py input.docx output.docx
```

---

## Creating New Documents

Generate .docx files with JavaScript, then validate. Install: `npm install -g docx`

### Setup
```javascript
const { Document, Packer, Paragraph, TextRun, Table, TableRow, TableCell, ImageRun,
        Header, Footer, AlignmentType, PageOrientation, LevelFormat, ExternalHyperlink,
        InternalHyperlink, Bookmark, FootnoteReferenceRun, PositionalTab,
        PositionalTabAlignment, PositionalTabRelativeTo, PositionalTabLeader,
        TabStopType, TabStopPosition, Column, SectionType,
        TableOfContents, HeadingLevel, BorderStyle, WidthType, ShadingType,
        VerticalAlign, PageNumber, PageBreak } = require('docx');

const doc = new Document({ sections: [{ children: [/* content */] }] });
Packer.toBuffer(doc).then(buffer => fs.writeFileSync("doc.docx", buffer));
```

### Validation
After creating the file, validate it. If validation fails, unpack, fix the XML, and repack.
```bash
python scripts/office/validate.py doc.docx
```

### Page Size

```javascript
// CRITICAL: docx-js defaults to A4, not US Letter
// Always set page size explicitly for consistent results
sections: [{
  properties: {
    page: {
      size: {
        width: 12240,   // 8.5 inches in DXA
        height: 15840   // 11 inches in DXA
      },
      margin: { top: 1440, right: 1440, bottom: 1440, left: 1440 } // 1 inch margins
    }
  },
  children: [/* content */]
}]
```

**Common page sizes (DXA units, 1440 DXA = 1 inch):**

| Paper | Width | Height | Content Width (1" margins) |
|-------|-------|--------|---------------------------|
| US Letter | 12,240 | 15,840 | 9,360 |
| A4 (default) | 11,906 | 16,838 | 9,026 |

**Landscape orientation:** docx-js swaps width/height internally, so pass portrait dimensions and let it handle the swap:
```javascript
size: {
  width: 12240,   // Pass SHORT edge as width
  height: 15840,  // Pass LONG edge as height
  orientation: PageOrientation.LANDSCAPE  // docx-js swaps them in the XML
},
// Content width = 15840 - left margin - right margin (uses the long edge)
```

### Styles (Override Built-in Headings)

Use Arial as the default font (universally supported). Keep titles black for readability.

```javascript
const doc = new Document({
  styles: {
    default: { document: { run: { font: "Arial", size: 24 } } }, // 12pt default
    paragraphStyles: [
      // IMPORTANT: Use exact IDs to override built-in styles
      { id: "Heading1", name: "Heading 1", basedOn: "Normal", next: "Normal", quickFormat: true,
        run: { size: 32, bold: true, font: "Arial" },
        paragraph: { spacing: { before: 240, after: 240 }, outlineLevel: 0 } }, // outlineLevel required for TOC
      { id: "Heading2", name: "Heading 2", basedOn: "Normal", next: "Normal", quickFormat: true,
        run: { size: 28, bold: true, font: "Arial" },
        paragraph: { spacing: { before: 180, after: 180 }, outlineLevel: 1 } },
    ]
  },
  sections: [{
    children: [

SKILL.md 不止这些内容,安装后可阅读全文。

技能包内容

共 61 个文件,合计 1.1 MiB

  • LICENSE.txt1.4 KiB
  • SKILL.md19.6 KiB
  • scripts/__init__.py1 B
  • scripts/accept_changes.py4.0 KiB
  • scripts/comment.py10.4 KiB
  • scripts/office/helpers/__init__.py0 B
  • scripts/office/helpers/merge_runs.py5.4 KiB
  • scripts/office/helpers/simplify_redlines.py5.6 KiB
  • scripts/office/pack.py4.9 KiB
  • scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd73.2 KiB
  • scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd6.8 KiB
  • scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd50.1 KiB
  • scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd624 B
  • scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd148.5 KiB
  • scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd1.2 KiB
  • scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd8.7 KiB
  • scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd14.4 KiB
  • scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd81.7 KiB
  • scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd1.2 KiB
  • scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd7.2 KiB
  • scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd6.2 KiB
  • scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd1.2 KiB
  • scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd880 B
  • scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd2.5 KiB
  • scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd3.4 KiB
  • scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd7.3 KiB
  • scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd22.8 KiB
  • scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd1.3 KiB
  • scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd236.6 KiB
  • scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd25.5 KiB
  • scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd24.7 KiB
  • scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd535 B
  • scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd5.6 KiB
  • scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd3.9 KiB
  • scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd167.4 KiB
  • scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd4.5 KiB
  • scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd1.9 KiB
  • scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd2.5 KiB
  • scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd2.8 KiB
  • scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd1.3 KiB
  • scripts/office/schemas/mce/mc.xsd3.1 KiB
  • scripts/office/schemas/microsoft/wml-2010.xsd25.9 KiB
  • scripts/office/schemas/microsoft/wml-2012.xsd3.7 KiB
  • scripts/office/schemas/microsoft/wml-2018.xsd901 B
  • scripts/office/schemas/microsoft/wml-cex-2018.xsd1.7 KiB
  • scripts/office/schemas/microsoft/wml-cid-2016.xsd1002 B
  • scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd600 B
  • scripts/office/schemas/microsoft/wml-symex-2015.xsd745 B
  • scripts/office/soffice.py5.2 KiB
  • scripts/office/unpack.py4.0 KiB
  • scripts/office/validate.py3.6 KiB
  • scripts/office/validators/__init__.py336 B
  • scripts/office/validators/base.py31.9 KiB
  • scripts/office/validators/docx.py16.0 KiB
  • scripts/office/validators/pptx.py9.6 KiB
  • scripts/office/validators/redlining.py8.7 KiB
  • scripts/templates/comments.xml2.5 KiB
  • scripts/templates/commentsExtended.xml2.5 KiB
  • scripts/templates/commentsExtensible.xml2.6 KiB
  • scripts/templates/commentsIds.xml2.6 KiB
  • scripts/templates/people.xml115 B

来源与审核

审核状态
尚未审核,内容来自上游来源
许可证
未说明

审核状态是平台对上架信息的记录,不构成对上游服务质量或可用性的担保。