This commit is contained in:
csh 2023-09-22 09:42:31 +08:00
parent 5f1064794d
commit d72d88d68a
5 changed files with 110 additions and 74 deletions

View File

@ -1,4 +1,4 @@
// Version 1.4.6
// Version 1.4.7
Function TOfficeObj(n);
Begin
@ -13922,14 +13922,11 @@ Type TDocumentBody = Class(DocObject)
p := new TParagraph(pNode);
//统计数字项目编号
numArr := array();
ilvl := -1;
numId := '';
numId := getNumPr('numId', docx, p);
ilvl := getNumPr('Level', docx, p);
if not ilvl then ilvl := 0;
if ifarray(numIds) then Begin
sectPr.Append(p);
numId := p.Format.NumPr.Value('numId');
lvlStr := p.Format.NumPr.Value('Level');
if not ifnil(numId) and not ifnil(lvlStr) then Begin
ilvl := Class(TSXml).SafeStrToIntDef(lvlStr, -1);
if ilvl >= 0 and ilvl < 10 then Begin
if not istable(numIds[numId]) then
numIds[numId] := array(0,0,0,0,0,0,0,0,0,0);
@ -13942,13 +13939,12 @@ Type TDocumentBody = Class(DocObject)
numArr := numIds[numId];
End;
End;
End;
if bHeadList then Begin //统计大纲显示(目录)
styleId := p.Format.Value('StyleId', 1);
if styleId <> '' then Begin
obj := docx.StyleObject().GetStyleById(styleId);
if ifObj(obj) then Begin
level := obj.HeadingLevel();
level := getHeadingLevel(docx, obj);
iLevel := Class(TSXml).SafeStrToIntDef(level, -1);
if p.Text() <> "" and iLevel+1 >= UpperHeadingLevel and iLevel+1 <= LowerHeadingLevel then Begin
r[ind]['Level'] := strtoint(level);
@ -13989,6 +13985,40 @@ Type TDocumentBody = Class(DocObject)
return r;
End;
Function getNumPr(field, docx, p);
Begin
value := p.Format.NumPr.Value(field);
if value then return value;
styleId := p.Format.Value('StyleId', 1);
return getFieldByStyle(field, docx, docx.StyleObject().GetStyleById(styleid));
End;
Function getFieldByStyle(field, docx, obj);
Begin
if not ifObj(obj) then return '';
numId := obj.pPr.numPr.Value(field);
if numId = '' then
begin
id := o.Value('BasedOn');
return getNumIdByStyle(docx, docx.StyleObject().GetStyleById(id));
end
return numId;
End;
Function getHeadingLevel(docx, obj);
Begin
if not ifObj(obj) then return '';
o := obj;
level := obj.HeadingLevel();
if level = '' then
begin
id := o.Value('BasedOn');
return getHeadingLevel(docx, docx.StyleObject().GetStyleById(id));
end
return level;
End;
Function getPictureMaxId();
Begin
id := 0;
@ -15314,4 +15344,3 @@ Begin
return true;
return false;
End;

View File

@ -1,4 +1,4 @@
// Version 1.4.6
// Version 1.4.7
Type TSDocxFile = Class
///Version: V1.0 2022-09-20

View File

@ -1,4 +1,4 @@
// Version 1.4.6
// Version 1.4.7
Type TSExcelFile = Class
///Version: V1.0 2022-08-08

View File

@ -160,9 +160,9 @@ Type TTableContent = class
if ifObj(style) then
numStr := style.GetText(r[i]['ilvl'], r[i]['numArr']);
End
if numStr <> '' then run_t := numStr + ' ' + r[i]['Text'];
else run_t := r[i]['Text'];
r1.SetText(run_t);
run_t := class(TSXml).CurCodePageToUtf8(r[i]['Text']);
if numStr <> '' then run_t := numStr + ' ' + run_t;
r1.SetText(run_t, 1);
r2 := h.AddRun();
r2.rPr.noProof := true;
@ -203,7 +203,6 @@ Type TTableContent = class
r8.fldCharType := 'end';
_AddStdContent(p);
End;
p2 := TOfficeObj('TParagraph');

View File

@ -1,5 +1,13 @@
# 更新日志
## 2023-9-22
### V1.4.7
#### word
1. 修复项目符号属于样式时,生成目录无法识别出项目符号问题
## 2023-9-19
### V1.4.6
@ -7,8 +15,8 @@
#### word
1. 修复表格存在合并单元格,生成目录报错问题
2. 修复单元格添加run对象设置样式不生效问题
3. 修复插入word后中文样式重复问题
2. 修复单元格添加 run 对象,设置样式不生效问题
3. 修复插入 word 后,中文样式重复问题
### excel
@ -18,7 +26,7 @@
#### excel
1. 修复`NewSheet`excel打开遇到提示错误问题
1. 修复`NewSheet`excel 打开遇到提示错误问题
## 2023-8-30
@ -30,7 +38,7 @@
#### excel
1. 修复`NewSheet`excel打开遇到提示错误问题
1. 修复`NewSheet`excel 打开遇到提示错误问题
## 2023-8-28
@ -40,7 +48,7 @@
1. 修复`insertFile`样式错误问题
2. 修复`insertFile`后删除段落再新增段落位置错误问题
3. 修复生成目录中文编码未转换导致word打开失败问题
3. 修复生成目录中文编码未转换导致 word 打开失败问题
## 2023-8-22
@ -56,7 +64,7 @@
#### word
支持插入另一个word内容`InsertFile(alias, fileName, posOpt)`
支持插入另一个 word 内容`InsertFile(alias, fileName, posOpt)`
## 2023-8-11
@ -64,7 +72,7 @@
#### word
修复插入表格后设置样式ID无法全部生效问题
修复插入表格后,设置样式 ID 无法全部生效问题
## 2023-8-10
@ -72,7 +80,7 @@
#### word
支持三级以内目录设置字体一级目录样式ID为`TOC1`二级目录样式ID为`TOC2`,三级为`TOC3`,通过样式设置相关属性即可修改目录字体
支持三级以内目录设置字体,一级目录样式 ID 为`TOC1`,二级目录样式 ID 为`TOC2`,三级为`TOC3`,通过样式设置相关属性即可修改目录字体
## 2023-8-7
@ -80,7 +88,7 @@
#### word
支持`AddHeading`时传入样式Id
支持`AddHeading`时传入样式 Id
## 2023-8-2
@ -112,13 +120,13 @@
#### word
段落字体大小设置调整对齐VBA设置
段落字体大小设置调整,对齐 VBA 设置
## 2023-7-11
### V1.3.4
修复加密Bug
修复加密 Bug
## 2023-7-4
@ -130,11 +138,11 @@ word/excel 新增加密方法`SetPassword`,升级`OpenFile(alias, fileName, Pa
### V1.3.2
修复.net使用rdo2执行失败问题使用rdo2时候需调用`TOfficeInit()`初始化
修复.net 使用 rdo2 执行失败问题,使用 rdo2 时候,需调用`TOfficeInit()`初始化
#### word
1. 修复word模板`template.docx`执行失败问题
1. 修复 word 模板`template.docx`执行失败问题
## 2023-6-20
@ -154,7 +162,7 @@ word/excel 新增加密方法`SetPassword`,升级`OpenFile(alias, fileName, Pa
#### excel
1. 支持excel程序设置字体样式粗体斜体等此类问题的返回类型如`style.Font.Bold`返回`true 或 false`
1. 支持 excel 程序设置字体样式粗体,斜体等此类问题的返回类型,如`style.Font.Bold`返回`true 或 false`
## 2023-4-4
@ -170,7 +178,7 @@ word/excel 新增加密方法`SetPassword`,升级`OpenFile(alias, fileName, Pa
#### excel
1. 修复由.net客户端导出的excel兼容性问题`SetColWidth`、`Set/GetDefaultSheet`、`SetSheetHeaderFooter`
1. 修复由.net 客户端导出的 excel 兼容性问题,`SetColWidth`、`Set/GetDefaultSheet`、`SetSheetHeaderFooter`
## 2023-3-23
@ -239,7 +247,7 @@ word/excel 新增加密方法`SetPassword`,升级`OpenFile(alias, fileName, Pa
#### excel
1. Get相关方法重新Set后不再覆盖原有设置影响方法如下`Set(Get)PageMargins`,`Set(Get)CellHyperLink`,`Set(Get)PageLayout`,`Set(Get)CalcOptions`,`Set(Get)DefaultFont`,`Set(Get)SheetViewOptions`
1. Get 相关方法重新 Set 后不再覆盖原有设置,影响方法如下`Set(Get)PageMargins`,`Set(Get)CellHyperLink`,`Set(Get)PageLayout`,`Set(Get)CalcOptions`,`Set(Get)DefaultFont`,`Set(Get)SheetViewOptions`
## 2023-2-23
@ -276,7 +284,7 @@ word/excel 新增加密方法`SetPassword`,升级`OpenFile(alias, fileName, Pa
1. 新增`LoadFromMem`, `SavaToMem`
2. 新增重载方法`NewSheet`
3. 新增`SetCalcOptions`
4. 修复删除sheet报错问题
4. 修复删除 sheet 报错问题
## 2023-2-13
@ -312,7 +320,7 @@ word/excel 新增加密方法`SetPassword`,升级`OpenFile(alias, fileName, Pa
#### word
1. 修复获取段落样式ID失败问题
1. 修复获取段落样式 ID 失败问题
2. 修复文本框添加图片失败问题
#### excel
@ -369,8 +377,8 @@ word/excel 新增加密方法`SetPassword`,升级`OpenFile(alias, fileName, Pa
#### word
1. 新增ExecInnerTSl
2. 新增修改chart图数据
1. 新增 ExecInnerTSl
2. 新增修改 chart 图(数据)
3. 修复`TNumbering::AddStyleByInnerXml`错误
4. 完善帮助文档
@ -388,11 +396,11 @@ word/excel 新增加密方法`SetPassword`,升级`OpenFile(alias, fileName, Pa
#### word
1. 修复chart图兼容性问题
1. 修复 chart 图兼容性问题
### V1.0.6
中文自动转换API由`class(xlsxXml).CodePage('中文');`调整为`TOfficeApi().CodePage('中文');`
中文自动转换 API 由`class(xlsxXml).CodePage('中文');`调整为`TOfficeApi().CodePage('中文');`
## 2023-1-5
@ -402,15 +410,15 @@ word/excel 新增加密方法`SetPassword`,升级`OpenFile(alias, fileName, Pa
#### word
1. 修复 Properties执行报错
1. 修复 Properties 执行报错
2. 修复格式刷
#### excel
1. 移除API `JoinCellName`
1. 移除 API `JoinCellName`
2. 修改`RGBToHSL`与`HSLToRGB`返回值
3. 修复获取超链接`GetCellHyperLink`失败问题
4. 修复一个对象新建文件打开文件之后引发的xlsx文件错误问题
4. 修复一个对象新建文件,打开文件之后引发的 xlsx 文件错误问题
5. 修复`GetCoreProps`,`GetAppProps`失败问题
## 2022-12-30
@ -430,4 +438,4 @@ word/excel 新增加密方法`SetPassword`,升级`OpenFile(alias, fileName, Pa
5. 修复`SetRowVisible``GetRowVisible``SetSheetVisible`问题
如何设置字符集(中文支持)?
★用户的脚本可能是UFT8格式或可能是GBK码格式系统提供API自动设置当前字符集环境`class(xlsxXml).CodePage('中文');` 在文件头设置该代码后,系统会自动检测当前的环境字符集
用户的脚本可能是 UFT8 格式,或可能是 GBK 码格式,系统提供 API 自动设置当前字符集环境:`class(xlsxXml).CodePage('中文');` 在文件头设置该代码后,系统会自动检测当前的环境字符集