Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Unable to set the Function property of the PivotField class

by Michaelc (Initiate)
on Nov 18, 2014 at 21:07 UTC ( [id://1107649]=perlquestion: print w/replies, xml ) Need Help??

Michaelc has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to change Pivot table {Function} property to specify it is xlCount or xlAverage or xlSum etc. But I got the error msg below:

==========

Unable to set the Function property of the PivotField class

Win32::OLE(0.1711) error 0x80020009: "Exception occurred" in PROPERTYPUT "Function" at WeeklyRpt.pl line 138

==========

Here is the code. I am using Win32::OLE.

use strict; use Math::BigInt; use Cwd; use Time::Local; use POSIX qw(strftime); use Win32::OLE::Const 'Microsoft Excel'; # use OLE/Excel $Win32::OLE::Warn = 3; # die on errors... <<<...snip...>>> # Create worksheet after cases data sheet $act_sheet = $workbook->Worksheets->Add({After=>$ws_data}) or die Win3 +2::OLE->LastError(); #Get current active sheet name $act_sheet_name = $workbook->ActiveSheet->{Name}; #Get current acti +ve sheet name $act_sheet = $workbook -> Worksheets( "$act_sheet_name" ); $act_sheet->{name} = 'ClosedRegion'; #Change sheet name http://www. +perlmonks.org/bare/?node_id=417676 $pv_table = $ws_data->PivotTableWizard( { SourceType=>xlDatabase, Sour +ceData=>$data_rang, TableDestination=>'ClosedRegion!R3C1', TableNa +me=>"PivotTable2"} ); $pv_table->AddFields( "Owner Region" ); $pv_table->PivotFields("Owner Region")->{Orientation} = xlDataField; $pv_table->PivotFields("Owner Region")->{Function} = xlCount;

The last line code causes the problem. I have also ever tried

$pv_table->PivotFields("Owner Region")->SetProperty("Function",xlCount);

but does not work out either.

Could you help out?

Thank you!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1107649]
Approved by stevieb
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-03-19 07:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found