This commit is contained in:
csh 2024-07-18 17:26:41 +08:00
parent 5469ca318d
commit 037cb41560
6 changed files with 61 additions and 30 deletions

View File

@ -1,4 +1,4 @@
// Version 1.6.9 // Version 1.7.0
Function TOfficeObj(n); Function TOfficeObj(n);
Begin Begin
case lowercase(n) of case lowercase(n) of
@ -554,6 +554,7 @@ type TComment=class(NodeInfo)
Function Init(); Function Init();
Begin Begin
Visible := new BOOL(self, 'Visible');
Font := new TFont(self, 'rPr'); Font := new TFont(self, 'rPr');
//TODO... //TODO...
End; End;
@ -561,6 +562,7 @@ type TComment=class(NodeInfo)
Function InitRootNode(node); Function InitRootNode(node);
Begin Begin
RootObj := node; RootObj := node;
Visible.InitRootNode(node);
Font.InitRootNode(node); Font.InitRootNode(node);
End; End;
@ -584,7 +586,8 @@ type TComment=class(NodeInfo)
Function GetChildren(); override; Function GetChildren(); override;
Begin 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':'Text','name':'t','obj':XMLText,'attrEx':'','nodeType':'pcdata','attrName':'', 'desc':'', 'class':'')
,('field':'Space','name':'t','obj':Space,'attrEx':'xml:space','nodeType':'','attrName':'', 'desc':'', 'class':'') ,('field':'Space','name':'t','obj':Space,'attrEx':'xml:space','nodeType':'','attrName':'', 'desc':'', 'class':'')
) union ExtNodes; ) union ExtNodes;
@ -593,6 +596,7 @@ type TComment=class(NodeInfo)
//Attributes //Attributes
//Nodes //Nodes
Visible;
Font; Font;
XMLText; XMLText;
Space; Space;
@ -3611,7 +3615,14 @@ type TBorders=class(NodeInfo)
Function GetChildren(); override; Function GetChildren(); override;
Begin 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':'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':'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') ,('field':'Bottom','name':Bottom.NodeName,'obj':Bottom,'attrEx':'','nodeType':'','attrName':'', 'desc':'', 'class':'TBorder')
@ -3624,6 +3635,13 @@ type TBorders=class(NodeInfo)
XMLDiagonalUp; XMLDiagonalUp;
//Nodes //Nodes
Color;
ColorIndex;
LineStyle;
Value;
Weight;
ThemeColor;
TintAndShade;
Left; Left;
Right; Right;
Top; Top;
@ -13223,10 +13241,18 @@ Type TDocumentBody = Class(DocObject)
end end
if multiLine then Begin if multiLine then Begin
defaultParagraph.node_ := nil; para := new TParagraph();
defaultParagraph.Run.ClearText(); if istable(customCell) and ifObj(customCell[i, j, 1]) then
defaultParagraph.Run.SetText(tbl.Data_[i, j]); para.PPr := customCell[i, j, 1];
tcNode.InsertEndChild(defaultParagraph.Marshal()); 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 End
else Begin else Begin
pNode := tcNode.InsertEndChild('element', 'w:p'); pNode := tcNode.InsertEndChild('element', 'w:p');

View File

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

View File

@ -3,9 +3,9 @@ Type NodeInfo = class
public public
Function Create(parentObj, name); Function Create(parentObj, name);
Begin Begin
if ifObj(parentObj) then if ifObj(parentObj) then
NodeUri := parentObj.NodeUri = '' ? name : (parentObj.NodeUri + '/' + name); NodeUri := parentObj.NodeUri = '' ? name : (parentObj.NodeUri + '/' + name);
else else
NodeUri := ''; NodeUri := '';
NodeName := name; NodeName := name;
ExtAttr := array(); ExtAttr := array();
@ -52,7 +52,7 @@ public
attrs := GetAttrsEx(); attrs := GetAttrsEx();
lName := lowerCase(name); lName := lowerCase(name);
r := sselect * from attrs where lName = lowerCase([0]) end; r := sselect * from attrs where lName = lowerCase([0]) end;
if istable(r) then if istable(r) then
begin begin
node.DeleteAttribute(r[1]); node.DeleteAttribute(r[1]);
return true; return true;
@ -72,7 +72,6 @@ public
return false; return false;
End; End;
Function GetAttrs(); virtual; Function GetAttrs(); virtual;
Begin Begin
return ExtAttr; return ExtAttr;
@ -190,7 +189,7 @@ public
attrs := GetAttrsEx(); attrs := GetAttrsEx();
lName := lowerCase(name); lName := lowerCase(name);
r := sselect * from attrs where lName = lowerCase([0]) end; r := sselect * from attrs where lName = lowerCase([0]) end;
if istable(r) then if istable(r) then
begin begin
value := node.GetAttribute(r[1]); value := node.GetAttribute(r[1]);
return nottransferable ? value : trystrtofloat(value, r) ? r : value; return nottransferable ? value : trystrtofloat(value, r) ? r : value;
@ -201,7 +200,7 @@ public
if istable(r) then Begin if istable(r) then Begin
r := r[0]; r := r[0];
node := node.FirstChildElement(r['name']); 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 not ifObj(node) then return nil;
if r['nodeType'] = 'pcdata' then //返回文本串 if r['nodeType'] = 'pcdata' then //返回文本串
return node.GetText(); return node.GetText();
@ -278,7 +277,7 @@ private
NodeName := ReplaceStr(NodeName, k, v); NodeName := ReplaceStr(NodeName, k, v);
end end
End End
Function ReplaceName(name); Function ReplaceName(name);
Begin Begin
for k,v in ReplaceArr do Begin for k,v in ReplaceArr do Begin

View File

@ -1,4 +1,4 @@
// Version 1.6.9 // Version 1.7.0
Type TSXlsxFile = Class Type TSXlsxFile = Class
///Version: V1.0 2022-08-08 ///Version: V1.0 2022-08-08
///适用于 Microsoft Excel? 2007 及以上版本创建的电子表格文档。支持 XLSX / XLSM / XLTM / XLTX 等多种文档格式。 ///适用于 Microsoft Excel? 2007 及以上版本创建的电子表格文档。支持 XLSX / XLSM / XLTM / XLTX 等多种文档格式。
@ -223,7 +223,7 @@ Type TSXlsxFile = Class
// 处理cell设定的样式 // 处理cell设定的样式
if not ifarray(opt) then opt := array(); if not ifarray(opt) then opt := array();
workbook_.SetCellStyleOpt(sheet_name, axis, opt); 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); return workbook_.SetCellValue(sheet_name, axis, value, opt);
End; End;

View File

@ -619,7 +619,7 @@ Type xlsxWorkBook = Class
//app.xml //app.xml
app := GetXmlFileObj(class(TSXml).GetFileName('docProps_app')); app := GetXmlFileObj(class(TSXml).GetFileName('docProps_app'));
vector := app.FirstChildElement('Properties').FirstChildElement('TitlesOfParts').FirstChildElement('vt:vector'); vector := app.FirstChildElement('Properties').FirstChildElement('TitlesOfParts').FirstChildElement('vt:vector');
vector.SetAttribute('size', sheetId); vector.SetAttribute('size', sheetsCount_+1);
vector.InsertEndChild('element', 'vt:lpstr', destSheet); vector.InsertEndChild('element', 'vt:lpstr', destSheet);
//[Content_Types].xml //[Content_Types].xml

View File

@ -1,12 +1,18 @@
# 更新日志 # 更新日志
## 2023-5-6 ## 2024-7-8
### excel
1. 修复`CopySheet`操作后,文件报错问题
## 2024-5-6
### excel ### excel
1. 修复单元格继承列样式失败问题 1. 修复单元格继承列样式失败问题
## 2023-4-12 ## 2024-4-12
### V1.6.8 ### V1.6.8
@ -14,7 +20,7 @@
1. 修复`SetCellValue`单元格对列样式的识别,不需要手动用格式刷对所有单元格刷新样式 1. 修复`SetCellValue`单元格对列样式的识别,不需要手动用格式刷对所有单元格刷新样式
## 2023-3-21 ## 2024-3-21
### V1.6.7 ### V1.6.7
@ -24,7 +30,7 @@
2. 新增`TPageNumType`对象 2. 新增`TPageNumType`对象
3. 扩展`TDocSection`方法,`AppendReference`和`AddReference`,前者是对已有的`Section`对象添加`TReference`对象,而后者是对新的`Section`对象添加 3. 扩展`TDocSection`方法,`AppendReference`和`AddReference`,前者是对已有的`Section`对象添加`TReference`对象,而后者是对新的`Section`对象添加
## 2023-3-14 ## 2024-3-14
### V1.6.6 ### V1.6.6
@ -33,7 +39,7 @@
1. 修复`TDocSection`节点获取错误 1. 修复`TDocSection`节点获取错误
2. 支持分栏自定义宽度 2. 支持分栏自定义宽度
## 2023-3-4 ## 2024-3-4
### V1.6.5 ### V1.6.5
@ -54,7 +60,7 @@
1. 修复目录生成陷入死循环问题 1. 修复目录生成陷入死循环问题
## 2023-2-23 ## 2024-2-23
### V1.6.3 ### V1.6.3
@ -62,7 +68,7 @@
1. 修复目录生成陷入死循环问题 1. 修复目录生成陷入死循环问题
## 2023-2-7 ## 2024-2-7
### V1.6.2 ### V1.6.2
@ -70,7 +76,7 @@
1. 修复设置段落属性`TextAlignment`失败问题 1. 修复设置段落属性`TextAlignment`失败问题
## 2023-2-5 ## 2024-2-5
### V1.6.1 ### V1.6.1
@ -78,7 +84,7 @@
1. 修复 excel 文件单元格原有类型与 tsl 类型转换报错问题(trystrtofloat) 1. 修复 excel 文件单元格原有类型与 tsl 类型转换报错问题(trystrtofloat)
## 2023-2-5 ## 2024-2-5
### V1.6.0 ### V1.6.0
@ -87,7 +93,7 @@
1. 兼容 Excel2016通过`NewSheet/InsertSheet`创建工作表不再提示修复错误 1. 兼容 Excel2016通过`NewSheet/InsertSheet`创建工作表不再提示修复错误
2. 修复带有表头的二维数组通过`InsertTable`写入数据只写入表头未写入数据问题 2. 修复带有表头的二维数组通过`InsertTable`写入数据只写入表头未写入数据问题
## 2023-1-31 ## 2024-1-31
### V1.5.9 ### V1.5.9
@ -99,7 +105,7 @@
1. 支持写入单元格内容时判断当前单元格的数据类型,并以单元格数据类型为准 1. 支持写入单元格内容时判断当前单元格的数据类型,并以单元格数据类型为准
## 2023-1-17 ## 2024-1-17
### V1.5.7 ### V1.5.7
@ -107,7 +113,7 @@
1. 修复单元格写入浮点数数据 bug如写入 0.0excel 某些版本打开会显示 0.00000000000000000 1. 修复单元格写入浮点数数据 bug如写入 0.0excel 某些版本打开会显示 0.00000000000000000
## 2023-1-11 ## 2024-1-11
### V1.5.6 ### V1.5.6