【问题标题】:Getting to charts embedded in Excel worksheet获取嵌入在 Excel 工作表中的图表
【发布时间】:2012-06-04 16:14:42
【问题描述】:

我正在尝试使用以下 Perl 代码对 Excel 工作表中的图表进行一些修改:

    $ex = Win32::OLE->new ('Excel.Application')
        or confess "could not instantiate Excel.Application: $!\n";

    my $workbook = $ex->Workbooks->Open ($file)
        or confess "failed to open $file: $!";

    my $charts_ws = $workbook->Worksheets ("Charts");
    my $charts_col = $charts_ws->ChartObjects;

    for (my $i = 0; $i != $charts_col->Count; ++$i)
    {
        my $chart = $charts_col->Item ($i); # XXX the problem is here
    }

    $workbook->Close;

XXX 标记线之前,一切似乎都有效。不幸的是,我收到以下错误:

Win32::OLE(0.1709) error 0x800a03ec
    in METHOD/PROPERTYGET "Item" at test.pl line 557

我无法破译0x800a03ec HRESULT 的值。

【问题讨论】:

    标签: perl excel com ole


    【解决方案1】:

    (为什么我总是在我在这里发布问题几秒钟后找到答案?)

    解决方案:我应该使用$charts_ws->ChartObjects ($i)->Chart,并且应该从索引 1 开始循环。

    【讨论】:

      猜你喜欢
      • 2011-06-13
      • 1970-01-01
      • 1970-01-01
      • 2016-04-26
      • 2019-01-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多