Hello Perl Monks!

I'm trying to generate charts from a newly created xls table. I use Spreadsheet::WriteExcel add_chart command. I tested the short code provided with the documentation and it worked perfectly. So the package is installed correctly.

However, after putting it into my code I get an error:
Tk::Error: Can't locate object method "add_chart" via package "Spreads +heet::WriteExcel::Worksheet" at C:\perl\KDC_v3charts.pl line 1352. main::analysis at C:\perl\KDC_v3charts.pl line 1352 Tk callback for .button4 Tk:__ANON__ at C:/Perl/site/lib/Tk.pm line 250 Tk::Button::butUp at C:/Perl/site/lib/Tk/Button.pm line 175 <ButtonRelease-1> <command bound to event>
My program looks generally like this (rough frame was created by Zooz):
#!/usr/bin/perl use strict; use warnings; use Tk; #GUI use Tk::DirTree; #GUI use Cwd; #Current working dir use Tk::NumEntry; #GUI use Spreadsheet::ParseExcel; #Excel I/O use Statistics::Descriptive; #Statistics use Spreadsheet::WriteExcel; #Excel I/O use Spreadsheet::WriteExcel:Worksheet; listed global variables Tk MainLoop, where there is main window created for user input, multip +le variables, and the submit button: $ZWIDGETS{'Button3'} = $MW->Button( -text => 'SUBMIT FOR ANALYSIS', -command => 'main::analysis', )->grid( -row => 15, -column => 0, -sticky => 'w', -padx => 5, -pady => 5, ) sub analysis { importing data from an input file multiple statistical calculations creating a new output xls file via my $EXworkbook = Spreadsheet::WriteExcel->new("output.xls") my $EXworksheet = $EXworkbook->add_worksheet('Worksheet1') writing statistical calculations into worksheet }
Works great! But... Then I tried to add new charts via
my $chart = $EXworksheet->add_chart( type => 'column', embedded => 1 )
If I try to embedd this into the main 'analysis' sub I get the above error.

If I try to place it as a separate sub (either within main sub or outside).... nothing happens

The package should be ok, since the standalone code generates charts. Any thoughts? Thanks.

In reply to Tk / Spreadsheet::WriteExcel Charts problem by marcinski

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.