【问题标题】:Perl Win32::OLE Word Cell TextPerl Win32::OLE Word 单元格文本
【发布时间】:2012-11-28 13:20:51
【问题描述】:

文本被截断。我已经按照文档对单元格范围和文本选项进行了编码,但是每个单元格的第一个字符被截断,并且只打印每个单元格的最后一句话。不确定这是否与单元格格式有关,但有些单元格有正确的对齐方式。

任何帮助都会很棒...这里是代码

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;

【问题讨论】:

    标签: perl


    【解决方案1】:

    可以尝试使用 visible=1 吗?我记得面临可见 = 0 的 ole 对象的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-07
      • 1970-01-01
      • 1970-01-01
      • 2011-10-30
      • 2012-10-22
      相关资源
      最近更新 更多