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);
Begin
case lowercase(n) of

View File

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

View File

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

View File

@ -118,7 +118,7 @@ Type TTableContent = class
tab := TOfficeObj('TTabStop');
tab.Val := 'right';
tab.leader := 'dot';
tab.Position := 8306;
tab.Position := TOfficeApi().Get("TTableContent-tab-position") ?: 8306;
p.Format.Tabs.Add(0, tab);
if first then Begin
//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
### V1.7.8
❗解决`TSDocxFile`和`TSXlsxFile`内存泄露
### word
#### word
1. **fix**`CreateTable`由于`fieldnames.tsf`差异报错