This commit is contained in:
csh 2023-07-04 14:16:27 +08:00
parent ce331f4417
commit f46240850e
5 changed files with 49 additions and 9 deletions

Binary file not shown.

View File

@ -1,4 +1,4 @@
// Version 1.3.3
// Version 1.3.4
Function TOfficeObj(n);
Begin

View File

@ -1,4 +1,4 @@
// Version 1.3.3
// Version 1.3.4
Type TSDocxFile = Class
///Version: V1.0 2022-09-20
@ -18,7 +18,17 @@ Type TSDocxFile = Class
Function Create(alias, fname); overload;
Begin
init();
OpenFile(alias, fname);
OpenFile(alias, fname, nil);
End;
///构造函数打开已经存在的docx文件
///alias: string文件目录别名
///fname: string文件名
///passwd: string密码
Function Create(alias, fname, passwd); overload;
Begin
init();
OpenFile(alias, fname, passwd);
End;
Function Destory();
@ -34,11 +44,12 @@ Type TSDocxFile = Class
///打开docx文件
///alias: string文件目录别名
///fname: string文件名
///[passwd]: string密码
///返回:[err, errmsg]
Function OpenFile(alias, fname);
Function OpenFile(alias, fname, passwd);
Begin
if not ifObj(zipfile_) then return array(-1, 'Create ZipFile object fail.');
[err, errmsg] := zipfile_.Open(alias, fname);
[err, errmsg] := zipfile_.Open(alias, fname, passwd);
if err=0 then Begin
document_ := new docxDocument(zipfile_);
End;
@ -56,6 +67,12 @@ Type TSDocxFile = Class
End;
return array(err, errmsg);
End;
///设置密码
Function SetPassword(passwd)
Begin
if not ifnil(passwd) then zipfile_.Password := passwd;
End;
///保存文件
///返回: [err, info]

View File

@ -1,4 +1,4 @@
// Version 1.3.3
// Version 1.3.4
Type TSExcelFile = Class
///Version: V1.0 2022-08-08
@ -18,7 +18,17 @@ Type TSExcelFile = Class
Function Create(alias, fname); overload;
Begin
init();
OpenFile(alias, fname);
OpenFile(alias, fname, nil);
End;
///构造函数打开已经存在的excel文件
///alias: string文件目录别名
///fname: string文件名
///passwd: string密码
Function Create(alias, fname, passwd); overload;
Begin
init();
OpenFile(alias, fname, passwd);
End;
//析构函数
@ -35,12 +45,13 @@ Type TSExcelFile = Class
///打开excel文件
///alias: string文件目录别名
///fname: string文件名
///[passwd]: string密码
///返回: [err, errmsg]
Function OpenFile(alias, fname);
Function OpenFile(alias, fname, passwd);
Begin
init();
if not ifObj(zipfile_) then return array(-1, 'Create ZipFile object fail.');
[err, errmsg] := zipfile_.Open(alias, fname);
[err, errmsg] := zipfile_.Open(alias, fname, passwd);
if err=0 then Begin
workbook_ := new xlsxWorkBook(zipfile_);
workbook_.Load();
@ -69,6 +80,12 @@ Type TSExcelFile = Class
return zipfile_.Save();
End;
///设置密码
Function SetPassword(passwd)
Begin
if not ifnil(passwd) then zipfile_.Password := passwd;
End;
///打开二进制内容
///data: 二进制数据
///返回: [err, errmsg]

View File

@ -1,5 +1,11 @@
# 更新日志
## 2023-7-4
### V1.3.3
word/excel 新增加密方法`SetPassword`,升级`OpenFile(alias, fileName, Password)`
## 2023-6-26
### V1.3.2