This commit is contained in:
csh 2023-07-26 14:35:05 +08:00
parent 880e03c41a
commit ced0d6b04c
5 changed files with 61 additions and 27 deletions

View File

@ -1,4 +1,4 @@
// Version 1.3.6 // Version 1.3.7
Function TOfficeObj(n); Function TOfficeObj(n);
Begin Begin
@ -14237,12 +14237,13 @@ Type TCell = Class(TDocumentBody, TWTc)
Function Create(node);overload; Function Create(node);overload;
Begin Begin
Class(TDocumentBody).Create(node); Class(TDocumentBody).Create(node);
Create(nil, 'w:tc'); Create(node, 'w:tc');
End; End;
Function Create(pNode, name);overload; Function Create(pNode, name);overload;
Begin Begin
Class(TWTc).Create(pNode, 'w:tc'); Class(TWTc).Create(nil, 'w:tc');
InitRootNode(pNode);
name_ := 'w:tc'; name_ := 'w:tc';
mergeSpan_ := 0; mergeSpan_ := 0;
pPr_ := new TwpPr(); pPr_ := new TwpPr();
@ -14445,23 +14446,6 @@ Type TTable = Class(DocObject, TTableImpl)
TblGrid.GridCol := gridArr; TblGrid.GridCol := gridArr;
End; End;
Function RowHeight(row, height);
Begin
if row <= 0 or row > Rows() then return;
node := node_.FirstChildElement('w:tr');
cnt := row - 1;
while(cnt) do
begin
node := node.NextElement('w:tr');
cnt--;
end
trnode := node.FirstChildElement("w:trPr");
if not ifObj(trnode) then trnode := node.InsertFirstChild('element', 'w:trPr');
node := trnode.FirstChildElement('w:trHeight');
if not ifObj(node) then node := trnode.InsertFirstChild('element', 'w:trHeight');
node.SetAttribute('w:val', height);
End;
Property Format read readFormat; Property Format read readFormat;
Function readFormat(); Function readFormat();
Begin Begin
@ -14519,6 +14503,45 @@ Type TTable = Class(DocObject, TTableImpl)
TblGrid.GridCol[n-1]['obj'].W := wth; TblGrid.GridCol[n-1]['obj'].W := wth;
End; End;
/// 设置行高
Function RowHeight(row, height);
Begin
if row <= 0 or row > Rows() then return;
node := node_.FirstChildElement('w:tr');
cnt := row - 1;
while(cnt) do
begin
node := node.NextElement('w:tr');
cnt--;
end
trnode := node.FirstChildElement("w:trPr");
if not ifObj(trnode) then trnode := node.InsertFirstChild('element', 'w:trPr');
node := trnode.FirstChildElement('w:trHeight');
if not ifObj(node) then node := trnode.InsertFirstChild('element', 'w:trHeight');
node.SetAttribute('w:val', height);
End;
Function Height(row);
Begin
if row <= 0 or row > Rows() then return nil;
node := node_.FirstChildElement('w:tr');
cnt := row - 1;
while(cnt) do
begin
node := node.NextElement('w:tr');
cnt--;
end
obj := new TwTr();
obj.InitRootNode(node);
return obj.TrPr.Value('Height');
End;
Function Width(col);
Begin
obj := Cell(1, col);
return obj.Format.Value('Width');
End;
///合并单元格 ///合并单元格
///del: bool是否删除其它单元格内容只保留左上单元格内容 ///del: bool是否删除其它单元格内容只保留左上单元格内容
Function Merge(top, left, bottom, right, del);overload; Function Merge(top, left, bottom, right, del);overload;

View File

@ -1,4 +1,4 @@
// Version 1.3.6 // Version 1.3.7
Type TSDocxFile = Class Type TSDocxFile = Class
///Version: V1.0 2022-09-20 ///Version: V1.0 2022-09-20
@ -49,6 +49,7 @@ Type TSDocxFile = Class
Function OpenFile(alias, fname, passwd); Function OpenFile(alias, fname, passwd);
Begin Begin
if not ifObj(zipfile_) then return array(-1, 'Create ZipFile object fail.'); if not ifObj(zipfile_) then return array(-1, 'Create ZipFile object fail.');
if zipfile_.FilesCount() > 0 then zipfile_ := new ZipFile();
[err, errmsg] := zipfile_.Open(alias, fname, passwd); [err, errmsg] := zipfile_.Open(alias, fname, passwd);
if err=0 then Begin if err=0 then Begin
document_ := new docxDocument(zipfile_); document_ := new docxDocument(zipfile_);

View File

@ -1,4 +1,4 @@
// Version 1.3.6 // Version 1.3.7
Type TSExcelFile = Class Type TSExcelFile = Class
///Version: V1.0 2022-08-08 ///Version: V1.0 2022-08-08
@ -49,8 +49,8 @@ Type TSExcelFile = Class
///返回: [err, errmsg] ///返回: [err, errmsg]
Function OpenFile(alias, fname, passwd); Function OpenFile(alias, fname, passwd);
Begin Begin
init();
if not ifObj(zipfile_) then return array(-1, 'Create ZipFile object fail.'); if not ifObj(zipfile_) then return array(-1, 'Create ZipFile object fail.');
if zipfile_.FilesCount() > 0 then zipfile_ := new ZipFile();
[err, errmsg] := zipfile_.Open(alias, fname, passwd); [err, errmsg] := zipfile_.Open(alias, fname, passwd);
if err=0 then Begin if err=0 then Begin
workbook_ := new xlsxWorkBook(zipfile_); workbook_ := new xlsxWorkBook(zipfile_);

View File

@ -1,10 +1,10 @@
Type NodeInfo = class Type NodeInfo = class
public public
Function Create(p, name); Function Create(parentObj, name);
Begin Begin
if ifObj(p) then if ifObj(parentObj) then
NodeUri := p.NodeUri = '' ? name : (p.NodeUri + '/' + name); NodeUri := parentObj.NodeUri = '' ? name : (parentObj.NodeUri + '/' + name);
else else
NodeUri := ''; NodeUri := '';
NodeName := name; NodeName := name;
@ -270,7 +270,7 @@ public
ExtNodes; ExtNodes;
//Parent; //Parent;
ReplaceArr; ReplaceArr;
RootObj; RootObj; // xml node
NodeUri:string; NodeUri:string;
children_; children_;
End End

View File

@ -1,5 +1,15 @@
# 更新日志 # 更新日志
## 2023-7-26
### V1.3.7
新增表格获取高度和宽度方法`table.Height(row) table.Width(col)`
#### word
新增对表格的行高设置`table.RowHeight(row, height)`
## 2023-7-19 ## 2023-7-19
### V1.3.6 ### V1.3.6