This commit is contained in:
csh 2025-02-28 13:41:23 +08:00
parent 39b7549665
commit c05b646104
5 changed files with 35 additions and 22 deletions

View File

@ -1,4 +1,4 @@
// Version 1.7.8 // Version 1.7.9
Function TOfficeObj(n); Function TOfficeObj(n);
Begin Begin
case lowercase(n) of case lowercase(n) of

View File

@ -1,4 +1,4 @@
// Version 1.7.8 // Version 1.7.9
Type TSDocxFile = Class Type TSDocxFile = Class
///Version: V1.0 2022-09-20 ///Version: V1.0 2022-09-20
///适用于 Microsoft Word docx格式文件 ///适用于 Microsoft Word docx格式文件
@ -123,7 +123,7 @@ Type TSDocxFile = Class
return document_.Body().Paragraphs(); return document_.Body().Paragraphs();
End; End;
///word文档最后一个段落 ///word文档最后一个段落
///返回TParagraph对象 ///返回TParagraph对象
Function LastParagraph(); Function LastParagraph();
Begin Begin
@ -237,7 +237,7 @@ Type TSDocxFile = Class
///tbl: TTable对象 ///tbl: TTable对象
///posOpt: 段落位置0 在DOCX文件开头-1 文件尾N 在第N段之后XmlNode节点对象或DocObject对象 在posOpt之后新添加表格 ///posOpt: 段落位置0 在DOCX文件开头-1 文件尾N 在第N段之后XmlNode节点对象或DocObject对象 在posOpt之后新添加表格
///customCell: 二维数组,自定义指定单元格的样式 ///customCell: 二维数组,自定义指定单元格的样式
/// 一行一列arr[0][0] := array(twtcPr, twpPr, twrPr);其中twtcPr是twtcPr对象twpPr是twpPr对象twrPr是twrPr对象 /// 一行一列arr[0][0] := array(twtcPr, twpPr, twrPr);其中twtcPr是twtcPr对象twpPr是twpPr对象twrPr是twrPr对象
///返回: TTable对象 ///返回: TTable对象
Function InsertTable(tbl, posOpt, customCell); Function InsertTable(tbl, posOpt, customCell);
Begin Begin
@ -267,12 +267,12 @@ Type TSDocxFile = Class
return document_.Body().Sections(index); return document_.Body().Sections(index);
End; End;
///获取Structured Document Tag ///获取Structured Document Tag
///返回TSdt集合 ///返回TSdt集合
Function Sdts(); Function Sdts();
Begin Begin
return document_.Body().Sdts(); return document_.Body().Sdts();
End; End;
///添加章节 ///添加章节
///sessionTDocSection对象 ///sessionTDocSection对象
@ -607,16 +607,20 @@ Type TSDocxFile = Class
DocPrId_ := 0; DocPrId_ := 0;
ps := Paragraphs(); ps := Paragraphs();
for i:=0 to length(ps)-1 do Begin for i:=0 to length(ps)-1 do Begin
node := class(TSXml).GetNode(ps[i].node_, 'w:r/w:drawing/wp:inline/wp:docPr'); runs := ps[i].GetRuns();
if not ifObj(node) then for j:=0 to length(runs)-1 do Begin
node := class(TSXml).GetNode(ps[i].node_, 'w:r/w:pict/v:shape/v:textbox/w:txbxContent/wp:docPr'); node := class(TSXml).GetNode(runs[j].node_, 'w:drawing/wp:inline/wp:docPr');
if not ifObj(node) then if not ifObj(node) then
node := class(TSXml).GetNode(ps[i].node_, 'w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/wp:docPr'); node := class(TSXml).GetNode(runs[j].node_, 'w:drawing/wp:anchor/wp:docPr');
if ifObj(node) then Begin if not ifObj(node) then
id := class(TSXml).SafeStrToIntDef(node.GetAttribute('id'), 0); node := class(TSXml).GetNode(runs[j].node_, 'w:pict/v:shape/v:textbox/w:txbxContent/wp:docPr');
if id > DocPrId_ then if not ifObj(node) then
DocPrId_ := id; node := class(TSXml).GetNode(runs[j].node_, 'mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/wp:docPr');
break; if ifObj(node) then Begin
id := class(TSXml).SafeStrToIntDef(node.GetAttribute('id'), 0);
if id > DocPrId_ then
DocPrId_ := id;
End;
End; End;
End; End;
End; End;

View File

@ -1,4 +1,4 @@
// Version 1.7.8 // Version 1.7.9
Type TSXlsxFile = Class Type TSXlsxFile = Class
///Version: V1.0 2022-08-08 ///Version: V1.0 2022-08-08
///适用于 Microsoft Excel? 2007 及以上版本创建的电子表格文档。支持 XLSX / XLSM / XLTM / XLTX 等多种文档格式。 ///适用于 Microsoft Excel? 2007 及以上版本创建的电子表格文档。支持 XLSX / XLSM / XLTM / XLTX 等多种文档格式。

View File

@ -118,7 +118,7 @@ Type TTableContent = class
tab := TOfficeObj('TTabStop'); tab := TOfficeObj('TTabStop');
tab.Val := 'right'; tab.Val := 'right';
tab.leader := 'dot'; tab.leader := 'dot';
tab.Position := 8306; tab.Position := TOfficeApi().Get("TTableContent-tab-position") ?: 8306;
p.Format.Tabs.Add(0, tab); p.Format.Tabs.Add(0, tab);
if first then Begin if first then Begin
//fldCharType //fldCharType

View File

@ -1,12 +1,21 @@
# 更新日志 # 更新日志
## 2025-2-28
### V1.7.9
#### word
1. **feat**:支持目录自定义宽度`TOfficeApi().Get("TTableContent-tab-position")`
2. **fix**插入图片id计算错误导致`office 2016 16.0.4266`版本不兼容
## 2025-1-22 ## 2025-1-22
### V1.7.8 ### V1.7.8
❗解决`TSDocxFile`和`TSXlsxFile`内存泄露 ❗解决`TSDocxFile`和`TSXlsxFile`内存泄露
### word #### word
1. **fix**`CreateTable`由于`fieldnames.tsf`差异报错 1. **fix**`CreateTable`由于`fieldnames.tsf`差异报错