in reply to OLE - updating a chart in an excel spreadsheet

First I must say I agree with NetWallah about the importance of posting the errormessage AND the offending linenumber.

So now I'm guessing that the line

### Create a refrence to @items and insert it into excel $Range->{Value} = [\@items];
could be part of your troubles.

#!perl -w use strict; use Data::Dumper; my @items= ('A','B','C'); print Dumper(\@items); print Dumper([\@items]); __OUTPUT__ $VAR1 = [ 'A', 'B', 'C' ]; $VAR1 = [ [ 'A', 'B', 'C' ] ];
HTH

Replies are listed 'Best First'.
Re: Re: OLE - updating a chart in an excel spreadsheet
by Rom399 (Initiate) on Mar 17, 2004 at 13:32 UTC
    Every thing up to here works, soon as i put in this bit of code i get the perl interpreter crash hence no error messages.
    ### Here we update the graphs sourcedata my $Chart1 = $RequestsSheet->ChartObjects("Chart 1"); $Chart1->Activate(); my $name = $Chart1->Name(); print "Chart1 Name: ", $name ,"\n";\ $RequestsSheet->ChartObjects("Chart 1")->Activate(); ############### This line here blows everything up. $Chart1->SetSourceData({Source => '=Data!\$A\$2:\$A\$295'} +);
    I have tried to update the Chart1 sourceData this way as well also get the perl interpreter to crash. No error messages.
    ### Here we update the graphs sourcedata my $Chart1 = $RequestsSheet->ChartObjects("Chart 1"); my $sourceRange = "A1:A295,G1:G295"; my $Chart1Range = $DataSheet->Range($sourceRange); ############### This line here blows everything up. $Chart1->SetSourceData({Source =>$Chart1Range,PlotBy => xl +Columns});

      You don't need to escape the $ in a single quoted string.
      # This line here blows everything up. $Chart1->SetSourceData({Source =>'=Data!\$A\$2:\$A\$295'}

      However, that doesn't fix the problem. The syntax of the second example using the Excel range seems correct but doesn't work. I tried several variations with no success.

      --
      John.

      This works for me

      my $Chart1Range = $DataSheet->Range("A1:A295,G1:G295"); $Chart1->SetSourceData($Chart1Range,xlColumns);