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

Hello,

I have a perl script that creates an excel-file and adds a chart to the workboook by use of the add_chart_ext command. It works fine.

Then I compress the script into an executable using CAVA packager. The script it self works fine but when I create the Excel file I get an error message telling me that "Chart type 'External' not supported in add_chart()". How come it works when I run it as a perl file but not as an executable?

All hints on how this can be solved are highly appreciated!

  • Comment on add_chart_ext does not work when compressed

Replies are listed 'Best First'.
Re: add_chart_ext does not work when compressed
by jmcnamara (Monsignor) on Apr 20, 2011 at 20:04 UTC
    That is a little odd,

    The warning message comes from the add_chart() method but the program is using the add_chart_ext() method which doesn't throw a warning like that.

    Are you using add_chart() and add_chart_ext() in the same program?

    In order to investigate this you will probably need to post a cut down version of the program that demonstrates the issue. Or at least show the sections of the program that generate charts.

    --
    John.

      Thanks for your reply! Below is the code that generates the error, if the user selects not to include a graph in the excel file (i.e. $graph==0) the error does not appear. I guess that means that it has to be the add_chart_ext command that generates the error

      if ($graph==1) { #Write values for run chart $hidden_worksheet->write(0,$stab_column_end+1,"Time"); $hidden_worksheet->write_col(1,$stab_column_end+1,\@time_data) +; $hidden_worksheet->write(0,$stab_column_end+2,"Speed 1"); $hidden_worksheet->write_col(1,$stab_column_end+2,\@speed_1_da +ta); $hidden_worksheet->write(0,$stab_column_end+3,"Speed 2"); $hidden_worksheet->write_col(1,$stab_column_end+3,\@speed_2_da +ta); $hidden_worksheet->write(0,$stab_column_end+4,"Speed 3"); $hidden_worksheet->write_col(1,$stab_column_end+4,\@Speed_3_da +ta); #Add run chart my $run_chart = $workbook->add_chart_ext('.\charts\run_chart.b +in',"Step response run"); $worksheet->store_formula('=Hidden data sheet!A1'); }

      There's alot more code generating a bunch information in the excel sheet before this snippet is executed, I don't know if that could affect anything. Furtheron, I have ensured that I have the bin-file run_chart at the indicated path.

      Is there anything I'm doing wrong here?

      Thank you in advance!

        I'm at a loss to see how this is happening in Spreadsheet::WriteExcel, either inside or outside of a Cava package.

        Could you add Devel::SimpleTrace to your program and post the stack trace of the failing code.

        --
        John.

Re: add_chart_ext does not work when compressed
by Anonymous Monk on Apr 21, 2011 at 01:41 UTC
    Maybe you didn't pack whatever files/modules add_chart... requires? Maybe it is a FAQ item ?
Re: add_chart_ext does not work when compressed
by samuelalfred (Sexton) on May 11, 2011 at 07:10 UTC
    Does anyone have an idea how to solve this? I'm really keen on getting this to work. If any more information is needed to identify the problem, just let me know and I'll post it.

    Thanks!

      From your stacktrace it looks like the underlying issue is caused by the fact that the Spreadsheet::WriteExcel::Chart::* modules are dynamically loaded via a factory method. This probably means that the Cava code analyser doesn't detect that they are required and doesn't load them in the package.

      A solution would probably be to explicitly include them in the your root program using "use":

      ... use Spreadsheet::WriteExcel; use Spreadsheet::WriteExcel::Chart::External; ...

      --
      John.

        Thank you, it finally works! I have before tried to force Cava to include these packages by explicitly telling it to do so in its settings but without success. It's firstly now when I included the use commande in my root script that the problem was solved.

        Thanks again for your help!

      Um, tell cava (by any means) to pack Spreadsheet/WriteExcel/Chart/External.pm -- I don't have cava anymore so I can't tell you what button to click, what jmcnamara said ought to work