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

Hello Monks, I am quite new here - so hi everyone!

I am using Spreadsheet::WriteExcel::Chart to insert some charts into a generated xls-file. Everything works out quite fine, just the legend makes some problems because it is not displaying the correct names. The strange thing is, that even when I use some popular demonstration-scripts on both of my machines the legend does not show what it should. Example:
#!/usr/bin/perl -w use strict; use Spreadsheet::WriteExcel; my $workbook = Spreadsheet::WriteExcel->new( 'chart_area.xls' ); my $worksheet = $workbook->add_worksheet(); my $bold = $workbook->add_format( bold => 1 ); # Add the worksheet data that the charts will refer to. my $headings = [ 'Number', 'Sample 1', 'Sample 2' ]; my $data = [ [ 2, 3, 4, 5, 6, 7 ], [ 1, 4, 5, 2, 1, 5 ], [ 3, 6, 7, 5, 4, 3 ], ]; $worksheet->write( 'A1', $headings, $bold ); $worksheet->write( 'A2', $data ); # Create a new chart object. In this case an embedded chart. my $chart = $workbook->add_chart( type => 'area', embedded => 1 ); # Configure the first series. (Sample 1) $chart->add_series( name => 'Sample 1', categories => '=Sheet1!$A$2:$A$7', values => '=Sheet1!$B$2:$B$7', ); # Configure the second series. (Sample 2) $chart->add_series( name => 'Sample 2', categories => '=Sheet1!$A$2:$A$7', values => '=Sheet1!$C$2:$C$7', ); # Add a chart title and some axis labels. $chart->set_title ( name => 'Results of sample analysis' ); $chart->set_x_axis( name => 'Test number' ); $chart->set_y_axis( name => 'Sample length (cm)' ); # Insert the chart into the worksheet (with an offset). $worksheet->insert_chart( 'D2', $chart, 25, 10 ); __END__
running this script it creates a xls-file in which the legend showes the name "Spalte B" an "Spalte C" (using ubuntu in german) In another script the legend has just numbers: 1,2... Does anyone have an idea how to get rid of this problem?

thx, Sebastian
  • Comment on no correct names in legend when using Spreadsheet::WriteExcel::chart
  • Download Code

Replies are listed 'Best First'.
Re: no correct names in legend when using Spreadsheet::WriteExcel::chart
by jmcnamara (Monsignor) on May 25, 2010 at 13:29 UTC

    Running your example program, which is that same as the one in the module Pod, produces the chart shown in the docs. The screenshot is taken directly from Excel for that example. As you can see the output is as you would expect.

    Perhaps the problem is with the application that you are using to view the output. What program/version are you using?

    --
    John.

      Omfg, you are right! I used Open Office to view the charts. But when I switch to Microsoft Office Mac the legend has the right names. Sometimes the solution is really simple ;)

      thx, Sebastian