不使用密码保存 Excel 个电子表格文件
Save Excel spreadsheet file without the password
我正在尝试打开受密码保护的 excel 并在没有密码的情况下保存它。
我知道密码。当我尝试 运行 下面的代码时,文件正在使用密码保存。
#!/usr/bin/perl
use strict;
use warnings,
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel *';
my $file = "in.xls";
my $outFile = "out.xls";
my $Excel = Win32::OLE->new ('Excel.Application', 'Quit');
$Excel->{'Visible'} = 0; #0 is hidden, 1 is visible
$Excel->{'DisplayAlerts'} = 0; #0 is hide alerts
my $Book = $Excel->Workbooks->Open({FileName => "$file", Password => 'test'});
my $Sheet = $Book->Worksheets('test');
$Sheet->Activate();
$Book->SaveAs({Filename=>"$outFile",FileFormat=>xlWorkbookNormal});
$Excel->Quit();
请指教
谢谢,
-安德烈
尝试:
$Book->Unprotect('test'); # Where 'test' is your password
我找到答案了:
$Book->SaveAs({Filename=>"$outFile",FileFormat=>xlWorkbookNormal, Password => undef});
谢谢大家。
我正在尝试打开受密码保护的 excel 并在没有密码的情况下保存它。 我知道密码。当我尝试 运行 下面的代码时,文件正在使用密码保存。
#!/usr/bin/perl
use strict;
use warnings,
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel *';
my $file = "in.xls";
my $outFile = "out.xls";
my $Excel = Win32::OLE->new ('Excel.Application', 'Quit');
$Excel->{'Visible'} = 0; #0 is hidden, 1 is visible
$Excel->{'DisplayAlerts'} = 0; #0 is hide alerts
my $Book = $Excel->Workbooks->Open({FileName => "$file", Password => 'test'});
my $Sheet = $Book->Worksheets('test');
$Sheet->Activate();
$Book->SaveAs({Filename=>"$outFile",FileFormat=>xlWorkbookNormal});
$Excel->Quit();
请指教
谢谢, -安德烈
尝试:
$Book->Unprotect('test'); # Where 'test' is your password
我找到答案了:
$Book->SaveAs({Filename=>"$outFile",FileFormat=>xlWorkbookNormal, Password => undef});
谢谢大家。