2
文本被截斷。我已經記錄了單元格區域和文本選項的編碼,但每個單元格的第一個字符被截斷,只打印每個單元格的最後一個句子。不知道這是否與單元格格式有關,但某些單元格具有正確的對齊方式。Perl Win32 :: OLE Word單元格文本
任何幫助將是巨大的......這裏是代碼
use warnings;
use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Word';
use Win32::OLE::Variant;
my $txt = "";
my $var1 = Win32::OLE::Variant->new(VT_BOOL, 'true');
# we are going be working with MS Word Objects
$Win32::OLE::Warn = 3;
# get already active Excel application or open new
my $Word = Win32::OLE->GetActiveObject('Word.Application')
|| Win32::OLE->new('Word.Application', 'Quit');
# open Excel file
my $Book = $Word->Documents- >Open("http://classroom.kleinisd.net/webs/lbalthazar/upload/2nd_six_weeks_calendar.docx");
#$Word->{Visible}= 0; # we don't need to see Word in an active window
# get the first table
my $table = $Word->ActiveDocument->Tables(1);
foreach my $row (1..4)
{
foreach my $col (1..5)
{
$txt = $table->Cell($row,$col)->Range->{Text};
print "$txt \n";
}
}
print "Closing document and Word\n";
#$Word->ActiveDocument->Close();
$Word->Quit;