title: Why can't I add a chart to my Excel spreadsheet with Perl's Spreadsheet::WriteExcel
body: <p>When creating a chart in a spreadsheet using <a href="http://search.cpan.org/dist/Spreadsheet-WriteExcel" rel="nofollow noreferrer">Spreadsheet::WriteExcel</a>, the file it creates keeps coming up with an error reading </p>
  
  <blockquote>
    <p>Excel found unreadable content in "Report.xls"</p>
  </blockquote>
  
  <p>and asks me if I want to recover it. I have worked it out that the problem line in the code is where I actually insert the chart, with</p>
  
  <pre><code>$chartworksheet-&gt;insert_chart(0, 0, $linegraph, 10, 10);
  </code></pre>
  
  <p>If I comment out this one line, the data is fine (but of course, there's no chart). The rest of the relevant code is as follows (any variables not defined here are defined earlier in the code, like <code>$lastrow</code>).</p>
  
  <pre><code>printf("Creating\n");
  my $chartworksheet = $workbook-&gt;add_worksheet('Graph');
  my $linegraph = $workbook-&gt;add_chart(type =&gt; 'line', embedded =&gt; 1);
  $linegraph-&gt;add_series(values =&gt; '=Data!$D$2:$D$lastrow', name =&gt; 'Column1');
  $linegraph-&gt;add_series(values =&gt; '=Data!$E$2:$E$lastrow', name =&gt; 'Column2');
  $linegraph-&gt;add_series(values =&gt; '=Data!$G$2:$G$lastrow', name =&gt; 'Column3');
  $linegraph-&gt;add_series(values =&gt; '=Data!$H$2:$H$lastrow', name =&gt; 'Column4');
  $linegraph-&gt;set_x_axis(name =&gt; 'x-axis');
  $linegraph-&gt;set_y_axis(name =&gt; 'y-axis');
  $linegraph-&gt;set_title(name =&gt; 'title');
  $linegraph-&gt;set_legend(position =&gt; 'bottom');
  $chartworksheet-&gt;activate();
  $chartworksheet-&gt;insert_chart(0, 0, $linegraph, 10, 10);
  printf("Finished\n");
  </code></pre>
  
  <p>I am at a total loss here, and I can't find any answers. Help please!</p>