[英]Why am I getting an exception when I try to set the value of a cell in Excel using Perl's Win32::OLE?
[英]Trying to understand why Perl Win32 OLE Excel Server threw an exception
試圖了解和診斷MS服務器2008上的Excel安裝有什么問題。請參閱下面的MWE。 這在我的Win筆記本電腦上可以正常工作,但在服務器上卻不那么出色。 通過干凈的登錄,它第一次可以正常運行,但是隨后的運行會失敗,並顯示錯誤文本:
Win32::OLE(0.1709) error 0x80010105: "The server threw an exception"
in PROPERTYPUT "DisplayAlerts" at mwe.pl line 20
第一次運行將excel.exe留在任務管理器中。 我想第二次嘗試是嘗試重新連接到該現有實例,但失敗了。 請問我怎么知道怎么了?
或者,如何在腳本完成后殺死Win32 :: OLE啟動的Excel進程,以便重新運行啟動新實例?
我的MWE:
use strict;
use warnings;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';
$Win32::OLE::Warn = 3; # Die on Errors.
# use existing instance if Excel is already running
my $Excel;
eval {$Excel = Win32::OLE->GetActiveObject('Excel.Application')};
die "Excel not installed" if $@;
unless (defined $Excel) {
print "another\n!";
$Excel = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;})
or die "Oops, cannot start Excel";
}
$Excel->{DisplayAlerts}=0;
$Excel->Quit();
undef $Excel;
您可以嘗試使用$ Excel-> {'DisplayAlerts'} = 0加上引號嗎? 我以這種方式使用它並且有效。 我想所有參考都是以這種方式進行的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.