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

Hi i am using the below mentioned cord to prepare a bar chart, but the problem i am facing is that on the y axis i.e the category values are coming as 1,2,3.... i want to change the values to something that i want like A,AB,XYZ so on, can someone help me on this

use strict; use Win32::OLE qw( in with ); use Win32::OLE::Variant; use Win32::OLE::Const 'Microsoft Excel'; use constant True=> 1; use constant False=> 0; my $Excel = Win32::OLE->new('Excel.Application', 'Quit') or die "$!"; $Excel->{'Visible'} = 1; my $Wkbook = $Excel->Workbooks->Add(); my $sheet1 = $Wkbook->Worksheets(1); #sample data $sheet1->Range("U10:W3")->{Value} = [[ 10, 20, 30 ], [ 5, 10, 20 ], [ 20, 7, 12 ], ]; my $range = $sheet1->Range( "U10:W3"); #add position, size chart1 my $chartObj = $sheet1->ChartObjects->Add( 2, 2, 600, 290 ); my $chart = $chartObj->Chart; $chart->{ChartType} = 96; $chart->SetSourceData($range); with($chart, HasLegend=> False , HasTitle=>True); $range = $sheet1->Range("U10:W63"); my $sc = $chart->SeriesCollection(1); my $ax = $chart->Axes; with($chart->PlotArea->Interior, ColorIndex=>-4142 ); with($chart, HasLegend=> False , HasTitle=> True ); with($chart->PlotArea->Border, Color=>0, LineStyle=> -4142, ColorIn +dex => -4142); with($chart->PlotArea->Interior, Color=> 16777215 ); with($chart->ChartArea->Font, Size=> 8 ); my $sc = $chart->SeriesCollection(1); my $pt = $sc->Points; with( $chart->ChartTitle, Text => 'JX'); with( $chart->ChartTitle->Font, Name=>'Arial', Size=>14, Bold=>True +); with( $ax->Item(xlValue), HasTitle => True); with( $ax->Item(xlValue)->AxisTitle, Text => "Frequency"); with( $ax->Item(xlCategory), HasTitle => True); with( $ax->Item(xlCategory)->AxisTitle, Text => "Age (Months)"); with( $sc->Interior, Color => 6697881 );

Replies are listed 'Best First'.
Re: Add category values
by cormanaz (Deacon) on Aug 08, 2011 at 13:51 UTC
    That's really more of an excel question than a perl question. You will probably find this helpful.