title: Using Spreadsheet::WriteExcel
body: <p>I want to extract some information from one Excel sheet and re-format it into another one. The data structure looks something like:</p>
  
  <pre><code>      col1      col2
  row1  School    1
  row2  Dean      John
  row3  No.stu.   55
  row4  some irrelevant stuff
  row5  School2   2
  row6  Dean      Tony
  row7  No. stu.  60
  row8  some irrelevant stuff
  row9  School    3
  row10 Dean      James
  row11 No.stu.   56
  row12 No. teacher 20
  </code></pre>
  
  <p>The output I would like to achieve is:</p>
  
  <pre><code>      col1 col2 col3
  row1 School Dean No.stu.  No. teacher
  row2 1      John  55
  row3 2      Tony  60
  row4 3      James 56       20
  </code></pre>
  
  <p>And the code I have been advised to use to extract information from Excel is the following (thanks to hdb from <em><a href="https://en.wikipedia.org/wiki/PerlMonks" rel="nofollow">PerlMonks</a></em>).</p>
  
  <pre><code>use strict; use warnings;
  
  use Spreadsheet::ParseExcel;
  
  my ($infile) = @ARGV;
  
  my $parser   = Spreadsheet::ParseExcel-&gt;new();
  my $workbook = $parser-&gt;parse($infile);
  die $parser-&gt;error unless defined $workbook;
  my ($worksheet) = $workbook-&gt;worksheets();
  
  my %data; # Accumulate data here
  my $row = 0;
  my $school = 0;
  while (1) {
      my $cell = $worksheet-&gt;get_cell($row, 0);
      last unless defined($cell);
      my $key =  $cell-&gt;value();
      my $data = $worksheet-&gt;get_cell($row++, 1)-&gt;value();
      if( $key eq "School" ) {
          $school = $data;
      }
      else {
          $data{$school}{$key} = $data;
      }
  }
  </code></pre>
  
  <p>Now the next step is to re-write everything into a new Excel sheet. How could I do that?</p>