# fsys.openXml.docx.editor 库模块帮助文档

[» Word 受控编辑](https://www.aardio.com/zh-cn/docs/library/fsys/openXml/docx/editor/)

## fsys.openXml.docx.editor 成员列表 <a id="fsys.openXml.docx.editor" href="#fsys.openXml.docx.editor">&#x23;</a>

基于公共 editor 的受控 Word 原生编辑；只改正文普通文字与普通表格，保留未修改部件原字节。  
不启动 Office/WPS，不执行宏；不更新域、页码、统计属性，不是修订/排版引擎。

### fsys.openXml.docx.editor.open() <a id="fsys.openXml.docx.editor.open" href="#fsys.openXml.docx.editor.open">&#x23;</a>
[返回对象:openXmlDocxEditorObject](#openXmlDocxEditorObject)

### fsys.openXml.docx.editor.open(path,options) <a id="fsys.openXml.docx.editor.open" href="#fsys.openXml.docx.editor.open">&#x23;</a>
打开只读源文件并创建编辑会话；支持 docx/docm/dotx/dotm 的 Transitional/Strict。  
含数字签名、启用编辑保护或修订跟踪时拒绝。options 为通用包/XML 限额。失败 null,err。

## openXmlDocxEditorObject 成员列表 <a id="openXmlDocxEditorObject" href="#openXmlDocxEditorObject">&#x23;</a>

### openXmlDocxEditorObject.changedParts() <a id="openXmlDocxEditorObject.changedParts" href="#openXmlDocxEditorObject.changedParts">&#x23;</a>
返回已显式修改的部件名数组；零匹配和同文替换不修改主部件。

### openXmlDocxEditorObject.close() <a id="openXmlDocxEditorObject.close" href="#openXmlDocxEditorObject.close">&#x23;</a>
关闭会话，可重复；不保存，已保存文件不受影响。

### openXmlDocxEditorObject.getTable(index) <a id="openXmlDocxEditorObject.getTable" href="#openXmlDocxEditorObject.getTable">&#x23;</a>
取得表格当前 rows 文本二维数组及 cells 的 text,editable,reason，物理坐标1起。  
不展开合并格，外层格预览不包括嵌套表。第三返回值 warnings。

### openXmlDocxEditorObject.listParagraphs() <a id="openXmlDocxEditorObject.listParagraphs" href="#openXmlDocxEditorObject.listParagraphs">&#x23;</a>
当前正文及直接普通表格内段落数组；index,text,tableIndex,row,column,editable,reason。  
含域/对象/修订等整段不编辑，预览文字可能不完整；不进入内容控件等未知块。  
序号1起，不等同于 Word COM 或 reader 的全部段落编号；成功第三返回值为 warnings。

### openXmlDocxEditorObject.listTables() <a id="openXmlDocxEditorObject.listTables" href="#openXmlDocxEditorObject.listTables">&#x23;</a>
普通正文表格数组，含嵌套表；index,depth,rowCount,columnCount,editable,reason。  
表级 editable 仅指结构；具体单元格能力看 getTable.cells。第三返回值 warnings。

### openXmlDocxEditorObject.mainPart <a id="openXmlDocxEditorObject.mainPart" href="#openXmlDocxEditorObject.mainPart">&#x23;</a>
按包关系定位的 Word 主部件。

### openXmlDocxEditorObject.path <a id="openXmlDocxEditorObject.path" href="#openXmlDocxEditorObject.path">&#x23;</a>
源文件完整路径。

### openXmlDocxEditorObject.replaceText(search,replacement,options) <a id="openXmlDocxEditorObject.replaceText" href="#openXmlDocxEditorObject.replaceText">&#x23;</a>
区分大小写的字面替换，可跨同段普通运行；不跨段落/标记/TAB/换行/链接边界。  
replacement 可为空串，继承首个命中运行格式；其余运行及非文字内容保留。  
options.paragraphs 为 listParagraphs 的1基序号数组（省略全体普通段落）；expectedCount 可为0，次数不符不提交。  
默认跳过受保护段落并报告 warnings，显式选中则报错；复杂域范围无法确认时拒绝。单次上限100000处。  
成功返回替换数,null,{warnings,scope,matched}；0是成功，失败 null,err。新文字不再次参与本次匹配。

### openXmlDocxEditorObject.save(outputPath,options) <a id="openXmlDocxEditorObject.save" href="#openXmlDocxEditorObject.save">&#x23;</a>
另存，默认不覆盖；overwrite=true 也不能覆盖源件/硬链接别名。  
必须保留文种扩展名；仅改主部件，其他部件保持原字节。失败不提交半成品；成功完整路径，失败null,err。

### openXmlDocxEditorObject.setTableCell(index,row,column,value) <a id="openXmlDocxEditorObject.setTableCell" href="#openXmlDocxEditorObject.setTableCell">&#x23;</a>
填单格，坐标1起；null跳过但仍校验表格和坐标，返回0或1，失败null,err。

### openXmlDocxEditorObject.setTableCells(index,values,options) <a id="openXmlDocxEditorObject.setTableCells" href="#openXmlDocxEditorObject.setTableCells">&#x23;</a>
在普通矩形、未合并表中填值，options.row/column 默认1；不增删行列。  
values 矩形二维数组；null跳过、空串清空、0/false保留；尾null/全null行请用 row@={length=N}。  
CRLF/CR/LF 分段，VT软换行，TAB制表；继承各目标格首段pPr/首运行rPr，保留表格/行/格格式与几何。  
清除目标格原文字链接；含域、书签、引用、修订、内容控件、嵌套表等的格拒绝，不丢弃对象。  
整次操作先验证后提交；返回写入格数，0合法，失败 null,err。
