This commit is contained in:
csh 2023-12-29 10:11:50 +08:00
parent fcb2a8e7b3
commit dc7d48c318
6 changed files with 58 additions and 38 deletions

View File

@ -1,4 +1,4 @@
// Version 1.5.4
// Version 1.5.5
Function TOfficeObj(n);
Begin
case lowercase(n) of
@ -13890,45 +13890,53 @@ Type TDocumentBody = Class(DocObject)
if name = 'w:p' and not ifObj(pNode.FirstChildElement('w:sectPr')) then
begin
pStyle := class(TSXml).GetNode(pNode, "w:pPr/w:pStyle");
level := nil;
if pStyle then
begin
styleId := pStyle.GetAttribute('w:val');
if styleId <> '' and (obj := docx.StyleObject().GetStyleById(styleId)) and ifObj(obj) then
begin
level := getHeadingLevel(docx, obj);
iLevel := Class(TSXml).SafeStrToIntDef(level, -1);
if iLevel+1 >= UpperHeadingLevel and iLevel+1 <= LowerHeadingLevel then Begin
//统计数字项目编号
p := new TParagraph(pNode);
text := p.Text();
if text = "" then continue;
numArr := array();
numId := getNumPr('numId', docx, p);
ilvl := getNumPr('Level', docx, p);
if not ilvl then ilvl := 0;
if ifarray(numIds) then Begin
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);
prev := numIds[numId, ilvl];
if prev then Begin
for i:=ilvl+1 to 9 do
numIds[numId, i] := 0;
End;
numIds[numId, ilvl]++;
numArr := numIds[numId];
End;
End;
r[ind]['Level'] := strtoint(level);
r[ind]['Paragraph'] := p;
r[ind]['Text'] := text;
r[ind]['numId'] := ifnumber(numId) ? integer(numId) : 0; //数字项目编号
r[ind]['ilvl'] := ilvl; //级别
r[ind]['numArr'] := numArr; //累加数字编码
ind++;
End;
end
end
else begin
level := class(TSXml).GetNode(pNode, "w:pPr/w:outlineLvl");
if ifObj(level) then level := level.GetAttribute("w:val");
end
if not ifnil(level) then
begin
iLevel := Class(TSXml).SafeStrToIntDef(level, -1);
if iLevel+1 >= UpperHeadingLevel and iLevel+1 <= LowerHeadingLevel then Begin
//统计数字项目编号
p := new TParagraph(pNode);
text := p.Text();
if text = "" then continue;
numArr := array();
numId := getNumPr('numId', docx, p);
ilvl := getNumPr('Level', docx, p);
if not ilvl then ilvl := 0;
if ifarray(numIds) then Begin
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);
prev := numIds[numId, ilvl];
if prev then Begin
for i:=ilvl+1 to 9 do
numIds[numId, i] := 0;
End;
numIds[numId, ilvl]++;
numArr := numIds[numId];
End;
End;
r[ind]['Level'] := strtoint(level);
r[ind]['Paragraph'] := p;
r[ind]['Text'] := text;
r[ind]['numId'] := ifnumber(numId) ? integer(numId) : 0; //数字项目编号
r[ind]['ilvl'] := ilvl; //级别
r[ind]['numArr'] := numArr; //累加数字编码
ind++;
End;
end
End
else if false and ifarray(numIds) and name = 'w:tbl' then Begin
tbl := TOfficeObj('TTable');

View File

@ -1,4 +1,4 @@
// Version 1.5.4
// Version 1.5.5
Type TSDocxFile = Class
///Version: V1.0 2022-09-20
///适用于 Microsoft Word docx格式文件

View File

@ -1,4 +1,4 @@
// Version 1.5.4
// Version 1.5.5
Type TSXlsxFile = Class
///Version: V1.0 2022-08-08
///适用于 Microsoft Excel? 2007 及以上版本创建的电子表格文档。支持 XLSX / XLSM / XLTM / XLTX 等多种文档格式。
@ -352,10 +352,9 @@ Type TSXlsxFile = Class
for i:=0 to length(data)-1 do Begin
for j:=0 to length(data[i])-1 do Begin
[err, cell] := CoordinatesToCellName(colNum + j, rowNum + i);
SetCellValue(sheet, cell, data[i][j]);
ret := SetCellValue(sheet, cell, data[i][j]);
if not ret then return array(1, "error")
End;
if err then
return array(err, info);
End;
return array(0, "OK");
End;

View File

@ -284,7 +284,7 @@ Type TTableContent = class
if ifObj(node) then
return node.GetAttribute('w:name');
bookMarkID := docx_.Document().GetBookMarkID();
return p.AddBookMark();
return p.AddBookMark(bookMarkID);
End;
Function _CheckNodes(name);

View File

@ -135,6 +135,7 @@ Type xlsxWorkBook = Class
end
ret := o.SetCellValue(axis, val, opt);
end
return ret;
End;
Function GetCellRichText(sheet, axis);

View File

@ -1,5 +1,17 @@
# 更新日志
## 2023-12-29
### V1.5.5
#### word
1. 修复生成的目录打开后重新生成页码可能产生页码失败问题
#### excel
1. 修复`InsertTable`与``SetCellValue`返回值问题
## 2023-12-18
### V1.5.4