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); Function TOfficeObj(n);
Begin Begin

View File

@ -1,4 +1,4 @@
// Version 1.3.3 // Version 1.3.4
Type TSDocxFile = Class Type TSDocxFile = Class
///Version: V1.0 2022-09-20 ///Version: V1.0 2022-09-20
@ -18,7 +18,17 @@ Type TSDocxFile = Class
Function Create(alias, fname); overload; Function Create(alias, fname); overload;
Begin Begin
init(); 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; End;
Function Destory(); Function Destory();
@ -34,11 +44,12 @@ Type TSDocxFile = Class
///打开docx文件 ///打开docx文件
///alias: string文件目录别名 ///alias: string文件目录别名
///fname: string文件名 ///fname: string文件名
///[passwd]: string密码
///返回:[err, errmsg] ///返回:[err, errmsg]
Function OpenFile(alias, fname); 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.');
[err, errmsg] := zipfile_.Open(alias, fname); [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_);
End; End;
@ -57,6 +68,12 @@ Type TSDocxFile = Class
return array(err, errmsg); return array(err, errmsg);
End; End;
///设置密码
Function SetPassword(passwd)
Begin
if not ifnil(passwd) then zipfile_.Password := passwd;
End;
///保存文件 ///保存文件
///返回: [err, info] ///返回: [err, info]
Function Save(); Function Save();

View File

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

View File

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