From 037cb4156042428a7fa3cc3b2ff69193d240f97b Mon Sep 17 00:00:00 2001 From: csh Date: Thu, 18 Jul 2024 17:26:41 +0800 Subject: [PATCH] v1.7.0 --- funcext/TSOffice/TOfficeObj.tsf | 40 +++++++++++++++++---- funcext/TSOffice/TSDocxFile.tsf | 2 +- funcext/TSOffice/TSUtils/NodeInfo.tsf | 13 ++++--- funcext/TSOffice/TSXlsxFile.tsf | 4 +-- funcext/TSOffice/worksheet/xlsxWorkBook.tsf | 2 +- 更新日志.md | 30 +++++++++------- 6 files changed, 61 insertions(+), 30 deletions(-) diff --git a/funcext/TSOffice/TOfficeObj.tsf b/funcext/TSOffice/TOfficeObj.tsf index 808780e..9490d3d 100644 --- a/funcext/TSOffice/TOfficeObj.tsf +++ b/funcext/TSOffice/TOfficeObj.tsf @@ -1,4 +1,4 @@ -// Version 1.6.9 +// Version 1.7.0 Function TOfficeObj(n); Begin case lowercase(n) of @@ -554,6 +554,7 @@ type TComment=class(NodeInfo) Function Init(); Begin + Visible := new BOOL(self, 'Visible'); Font := new TFont(self, 'rPr'); //TODO... End; @@ -561,6 +562,7 @@ type TComment=class(NodeInfo) Function InitRootNode(node); Begin RootObj := node; + Visible.InitRootNode(node); Font.InitRootNode(node); End; @@ -584,7 +586,8 @@ type TComment=class(NodeInfo) Function GetChildren(); override; Begin - return array(('field':'Font','name':Font.NodeName,'obj':Font,'attrEx':'','nodeType':'','attrName':'', 'desc':'', 'class':'TFont') + return array(('field':'Visible','name':Visible.NodeName,'obj':Visible,'attrEx':'','nodeType':'','attrName':'', 'desc':'', 'class':'BOOL') + ,('field':'Font','name':Font.NodeName,'obj':Font,'attrEx':'','nodeType':'','attrName':'', 'desc':'', 'class':'TFont') ,('field':'Text','name':'t','obj':XMLText,'attrEx':'','nodeType':'pcdata','attrName':'', 'desc':'', 'class':'') ,('field':'Space','name':'t','obj':Space,'attrEx':'xml:space','nodeType':'','attrName':'', 'desc':'', 'class':'') ) union ExtNodes; @@ -593,6 +596,7 @@ type TComment=class(NodeInfo) //Attributes //Nodes + Visible; Font; XMLText; Space; @@ -3611,7 +3615,14 @@ type TBorders=class(NodeInfo) Function GetChildren(); override; Begin - return array(('field':'Left','name':Left.NodeName,'obj':Left,'attrEx':'','nodeType':'','attrName':'', 'desc':'', 'class':'TBorder') + return array(('field':'Color','name':'Color','obj':Color,'attrEx':'','nodeType':'','attrName':'', 'desc':'', 'class':'') + ,('field':'ColorIndex','name':'ColorIndex','obj':ColorIndex,'attrEx':'','nodeType':'','attrName':'', 'desc':'', 'class':'') + ,('field':'LineStyle','name':'LineStyle','obj':LineStyle,'attrEx':'','nodeType':'','attrName':'', 'desc':'', 'class':'') + ,('field':'Value','name':'Value','obj':Value,'attrEx':'','nodeType':'','attrName':'', 'desc':'', 'class':'') + ,('field':'Weight','name':'Weight','obj':Weight,'attrEx':'','nodeType':'','attrName':'', 'desc':'', 'class':'') + ,('field':'ThemeColor','name':'ThemeColor','obj':ThemeColor,'attrEx':'','nodeType':'','attrName':'', 'desc':'', 'class':'') + ,('field':'TintAndShade','name':'TintAndShade','obj':TintAndShade,'attrEx':'','nodeType':'','attrName':'', 'desc':'', 'class':'') + ,('field':'Left','name':Left.NodeName,'obj':Left,'attrEx':'','nodeType':'','attrName':'', 'desc':'', 'class':'TBorder') ,('field':'Right','name':Right.NodeName,'obj':Right,'attrEx':'','nodeType':'','attrName':'', 'desc':'', 'class':'TBorder') ,('field':'Top','name':Top.NodeName,'obj':Top,'attrEx':'','nodeType':'','attrName':'', 'desc':'', 'class':'TBorder') ,('field':'Bottom','name':Bottom.NodeName,'obj':Bottom,'attrEx':'','nodeType':'','attrName':'', 'desc':'', 'class':'TBorder') @@ -3624,6 +3635,13 @@ type TBorders=class(NodeInfo) XMLDiagonalUp; //Nodes + Color; + ColorIndex; + LineStyle; + Value; + Weight; + ThemeColor; + TintAndShade; Left; Right; Top; @@ -13223,10 +13241,18 @@ Type TDocumentBody = Class(DocObject) end if multiLine then Begin - defaultParagraph.node_ := nil; - defaultParagraph.Run.ClearText(); - defaultParagraph.Run.SetText(tbl.Data_[i, j]); - tcNode.InsertEndChild(defaultParagraph.Marshal()); + para := new TParagraph(); + if istable(customCell) and ifObj(customCell[i, j, 1]) then + para.PPr := customCell[i, j, 1]; + else + para.PPr := defaultParagraph.pPr; + if istable(customCell) and ifObj(customCell[i, j, 2]) then + para.PPr.RPr := customCell[i, j, 2]; + else + para.PPr.RPr := defaultParagraph.pPr.rpr; + para.Run.SetText(tbl.Data_[i, j]); + para.Run.RPr := para.PPr.RPr; + tcNode.InsertEndChild(para.Marshal()); End else Begin pNode := tcNode.InsertEndChild('element', 'w:p'); diff --git a/funcext/TSOffice/TSDocxFile.tsf b/funcext/TSOffice/TSDocxFile.tsf index 74dfd9d..1c65424 100644 --- a/funcext/TSOffice/TSDocxFile.tsf +++ b/funcext/TSOffice/TSDocxFile.tsf @@ -1,4 +1,4 @@ -// Version 1.6.9 +// Version 1.7.0 Type TSDocxFile = Class ///Version: V1.0 2022-09-20 ///适用于 Microsoft Word docx格式文件 diff --git a/funcext/TSOffice/TSUtils/NodeInfo.tsf b/funcext/TSOffice/TSUtils/NodeInfo.tsf index 51858b2..0eb8225 100644 --- a/funcext/TSOffice/TSUtils/NodeInfo.tsf +++ b/funcext/TSOffice/TSUtils/NodeInfo.tsf @@ -3,9 +3,9 @@ Type NodeInfo = class public Function Create(parentObj, name); Begin - if ifObj(parentObj) then + if ifObj(parentObj) then NodeUri := parentObj.NodeUri = '' ? name : (parentObj.NodeUri + '/' + name); - else + else NodeUri := ''; NodeName := name; ExtAttr := array(); @@ -52,7 +52,7 @@ public attrs := GetAttrsEx(); lName := lowerCase(name); r := sselect * from attrs where lName = lowerCase([0]) end; - if istable(r) then + if istable(r) then begin node.DeleteAttribute(r[1]); return true; @@ -72,7 +72,6 @@ public return false; End; - Function GetAttrs(); virtual; Begin return ExtAttr; @@ -190,7 +189,7 @@ public attrs := GetAttrsEx(); lName := lowerCase(name); r := sselect * from attrs where lName = lowerCase([0]) end; - if istable(r) then + if istable(r) then begin value := node.GetAttribute(r[1]); return nottransferable ? value : trystrtofloat(value, r) ? r : value; @@ -201,7 +200,7 @@ public if istable(r) then Begin r := r[0]; node := node.FirstChildElement(r['name']); - if not ifObj(node) and r['nodeType'] = 'empty' then return false; + if not ifObj(node) and r['nodeType'] = 'empty' and not nottransferable then return false; if not ifObj(node) then return nil; if r['nodeType'] = 'pcdata' then //返回文本串 return node.GetText(); @@ -278,7 +277,7 @@ private NodeName := ReplaceStr(NodeName, k, v); end End - + Function ReplaceName(name); Begin for k,v in ReplaceArr do Begin diff --git a/funcext/TSOffice/TSXlsxFile.tsf b/funcext/TSOffice/TSXlsxFile.tsf index 03b70c5..b66ff16 100644 --- a/funcext/TSOffice/TSXlsxFile.tsf +++ b/funcext/TSOffice/TSXlsxFile.tsf @@ -1,4 +1,4 @@ -// Version 1.6.9 +// Version 1.7.0 Type TSXlsxFile = Class ///Version: V1.0 2022-08-08 ///适用于 Microsoft Excel? 2007 及以上版本创建的电子表格文档。支持 XLSX / XLSM / XLTM / XLTX 等多种文档格式。 @@ -223,7 +223,7 @@ Type TSXlsxFile = Class // 处理cell设定的样式 if not ifarray(opt) then opt := array(); workbook_.SetCellStyleOpt(sheet_name, axis, opt); - SetCellType(sheet, axis, value, opt); + SetCellType(sheet_name, axis, value, opt); return workbook_.SetCellValue(sheet_name, axis, value, opt); End; diff --git a/funcext/TSOffice/worksheet/xlsxWorkBook.tsf b/funcext/TSOffice/worksheet/xlsxWorkBook.tsf index ed0fec6..0788cc4 100644 --- a/funcext/TSOffice/worksheet/xlsxWorkBook.tsf +++ b/funcext/TSOffice/worksheet/xlsxWorkBook.tsf @@ -619,7 +619,7 @@ Type xlsxWorkBook = Class //app.xml app := GetXmlFileObj(class(TSXml).GetFileName('docProps_app')); vector := app.FirstChildElement('Properties').FirstChildElement('TitlesOfParts').FirstChildElement('vt:vector'); - vector.SetAttribute('size', sheetId); + vector.SetAttribute('size', sheetsCount_+1); vector.InsertEndChild('element', 'vt:lpstr', destSheet); //[Content_Types].xml diff --git a/更新日志.md b/更新日志.md index 4126db2..7c15654 100644 --- a/更新日志.md +++ b/更新日志.md @@ -1,12 +1,18 @@ # 更新日志 -## 2023-5-6 +## 2024-7-8 + +### excel + +1. 修复`CopySheet`操作后,文件报错问题 + +## 2024-5-6 ### excel 1. 修复单元格继承列样式失败问题 -## 2023-4-12 +## 2024-4-12 ### V1.6.8 @@ -14,7 +20,7 @@ 1. 修复`SetCellValue`单元格对列样式的识别,不需要手动用格式刷对所有单元格刷新样式 -## 2023-3-21 +## 2024-3-21 ### V1.6.7 @@ -24,7 +30,7 @@ 2. 新增`TPageNumType`对象 3. 扩展`TDocSection`方法,`AppendReference`和`AddReference`,前者是对已有的`Section`对象添加`TReference`对象,而后者是对新的`Section`对象添加 -## 2023-3-14 +## 2024-3-14 ### V1.6.6 @@ -33,7 +39,7 @@ 1. 修复`TDocSection`节点获取错误 2. 支持分栏自定义宽度 -## 2023-3-4 +## 2024-3-4 ### V1.6.5 @@ -54,7 +60,7 @@ 1. 修复目录生成陷入死循环问题 -## 2023-2-23 +## 2024-2-23 ### V1.6.3 @@ -62,7 +68,7 @@ 1. 修复目录生成陷入死循环问题 -## 2023-2-7 +## 2024-2-7 ### V1.6.2 @@ -70,7 +76,7 @@ 1. 修复设置段落属性`TextAlignment`失败问题 -## 2023-2-5 +## 2024-2-5 ### V1.6.1 @@ -78,7 +84,7 @@ 1. 修复 excel 文件单元格原有类型与 tsl 类型转换报错问题(trystrtofloat) -## 2023-2-5 +## 2024-2-5 ### V1.6.0 @@ -87,7 +93,7 @@ 1. 兼容 Excel2016,通过`NewSheet/InsertSheet`创建工作表不再提示修复错误 2. 修复带有表头的二维数组通过`InsertTable`写入数据只写入表头未写入数据问题 -## 2023-1-31 +## 2024-1-31 ### V1.5.9 @@ -99,7 +105,7 @@ 1. 支持写入单元格内容时判断当前单元格的数据类型,并以单元格数据类型为准 -## 2023-1-17 +## 2024-1-17 ### V1.5.7 @@ -107,7 +113,7 @@ 1. 修复单元格写入浮点数数据 bug,如写入 0.0,excel 某些版本打开会显示 0.00000000000000000 -## 2023-1-11 +## 2024-1-11 ### V1.5.6