保存没有密码的Excel电子表格文件

我试图打开密码保护的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 

参考: Workbook.Unprotect方法(Excel)

我想出了答案:

 $Book->SaveAs({Filename=>"$outFile",FileFormat=>xlWorkbookNormal, Password => undef}); 

多谢你们。