Hi @ all, in recent days I try to talk about Perl with Excel 2007 (about WIN32::OLE). I want to create a Pivot table + chart. But I couldn't create a chart Title. Please help me.... For a better understanding my perl code:
#! perl -w use warnings; use strict; use Win32::OLE ; my $excel = Win32::OLE->new('Excel.Application'); $excel->{'Visible'} = 1; my $workbook = $excel -> Workbooks -> Add; my $sheet = $workbook->Sheets("Tabelle1"); $sheet -> Range('A1')->{'Value'} = "Temp [°C]"; $sheet -> Range('B1')->{'Value'} = "Vcc [V]"; $sheet -> Range('C1')->{'Value'} = "Vio [V]"; $sheet -> Range('D1')->{'Value'} = "Ivcc [mA]"; $sheet -> Range('A2:D3')->{'Value'} = [ ['1', '2', '3', '4' ], ['5', '6', '7', '8' ], ]; my $sheet2 = $workbook-> Sheets -> Add; $sheet -> select; #&sheet2->Shapes->AddChart->Select; #ActiveChart->SetSourceData Source->Range("Tabelle4!$A$1:$C$18"); #$workbook->PivotChaches->Add{SourceType=>1,SourceData=>'Tabelle1!Z1S1 +:Z3S4'})->({TableDestination=>'Tabelle4!Z1S1', TableName=>'PivotTable +1'}); my $pivot=$workbook->PivotTableWizard( { SourceType => 1, SourceData => 'Tabelle1!Z1S1:Z3S4', TableDestination => "Tabelle4!Z1S1", TableName => "PivotTable1", HasAutoFormat => 1 }); $pivot->PivotFields("Vcc [V]")->{Orientation} = 1; # 4=xlDataField $pivot->PivotFields("Temp [°C]")->{Orientation} = 2; # 4=xlDataField $pivot->PivotFields("Vio [V]")->{Orientation} = 1; # 4=xlDataField $pivot->PivotFields("Ivcc [mA]")->{Orientation} = 4; # 4=xlDataField $pivot->PivotFields("Summe von Ivcc [mA]")->{Function} = 2; #{Caption} + = "Mittelwert von Ivcc [mA]"; $sheet2->Range('F1')->Select; my $chart=$sheet2->Shapes->AddChart(65); $sheet2->chartObjects("Diagramm 1")->Activate; $chart->{HasTitle} = 1; $chart->ChartTitle->{Text} = "Some Title"; $excel -> Quit;
The lines
$chart->{HasTitle} = 1; $chart->ChartTitle->{Text} = "Some Title";
didn't work. Why?

Some additional questions:

Where can I find information/documentation on the "Perl excel syntax"?

Can I control excel completely with the WIN32::OLE modul?

Thanks for working on this topic

Best Regards

jazzman

In reply to WIN32::OLE excel pivot Chart Title doesn't work by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.