diff --git a/funcext/TSOffice/TOfficeObj.tsf b/funcext/TSOffice/TOfficeObj.tsf index dc7038c..cf8da28 100644 --- a/funcext/TSOffice/TOfficeObj.tsf +++ b/funcext/TSOffice/TOfficeObj.tsf @@ -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'); diff --git a/funcext/TSOffice/TSDocxFile.tsf b/funcext/TSOffice/TSDocxFile.tsf index ac7294e..f21fca1 100644 --- a/funcext/TSOffice/TSDocxFile.tsf +++ b/funcext/TSOffice/TSDocxFile.tsf @@ -1,4 +1,4 @@ -// Version 1.5.4 +// Version 1.5.5 Type TSDocxFile = Class ///Version: V1.0 2022-09-20 ///适用于 Microsoft Word docx格式文件 diff --git a/funcext/TSOffice/TSXlsxFile.tsf b/funcext/TSOffice/TSXlsxFile.tsf index e5079ef..b845f19 100644 --- a/funcext/TSOffice/TSXlsxFile.tsf +++ b/funcext/TSOffice/TSXlsxFile.tsf @@ -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; diff --git a/funcext/TSOffice/document/TTableContent.tsf b/funcext/TSOffice/document/TTableContent.tsf index 897e39a..3cbf008 100644 --- a/funcext/TSOffice/document/TTableContent.tsf +++ b/funcext/TSOffice/document/TTableContent.tsf @@ -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); diff --git a/funcext/TSOffice/worksheet/xlsxWorkBook.tsf b/funcext/TSOffice/worksheet/xlsxWorkBook.tsf index efa7509..6118a6b 100644 --- a/funcext/TSOffice/worksheet/xlsxWorkBook.tsf +++ b/funcext/TSOffice/worksheet/xlsxWorkBook.tsf @@ -135,6 +135,7 @@ Type xlsxWorkBook = Class end ret := o.SetCellValue(axis, val, opt); end + return ret; End; Function GetCellRichText(sheet, axis); diff --git a/更新日志.md b/更新日志.md index f45e3f2..7a9348f 100644 --- a/更新日志.md +++ b/更新日志.md @@ -1,5 +1,17 @@ # 更新日志 +## 2023-12-29 + +### V1.5.5 + +#### word + +1. 修复生成的目录打开后重新生成页码可能产生页码失败问题 + +#### excel + +1. 修复`InsertTable`与``SetCellValue`返回值问题 + ## 2023-12-18 ### V1.5.4