title: making cells blank in and excel sheet using perl
body: <p>I have an excel sheet to which I need to empty some cells</p>
  
  <p>So far this is what it looks like:</p>
  
  <p>I open the sheet, and check for cells not empty in column M. 
  I add those cells to my array mistake
  and then I would like to make black all those cells and save the file (this step not working), as that file needs to be the input to anotherprogram/
  thanks!</p>
  
  <pre><code>$infile = $ARGV[0];
  
   $columns = ReadData($infile) or die "cannot open excel table\n\n";
   print "xls sheet contains $columns-&gt;[1]{maxrow} rows\n";
  
   my $xlsstartrow;
   if ( getExcel( A . 1 ) ne "text" ) {
  
  $xlsstartrow = 2;   
   }
   else 
   {
  $xlsstartrow = 4;
   }
  
  
   check_templates();
   print "done";
   sub check_templates {
  
  for ( $row = $xlsstartrow ; $row &lt; ( $columns-&gt;[1]{maxrow} + 1 ) ; $row++ ) {
  
      if (getExcel(M . $row) ne ""  ){ 
  
          $cell = "M" . $row ;
  
          push(@mistakes,$cell);
  
      }
  
  }
   rewritesheet(@mistakes);
  
  
   }
  
   sub rewritesheet {
  
  
  my $FileName = $infile;
   my $parser   = Spreadsheet::ParseExcel::SaveParser-&gt;new();
   my $template = $parser-&gt;Parse($FileName);
  my $worksheet = $template-&gt;worksheet(0);
  
  
  my $row      = 0;
  my $col      = 0;
  # Get the format from the cell
  
  my $format   = $template-&gt;{Worksheet}[$sheet]
                         -&gt;{Cells}[$row][$col]
                          -&gt;{FormatNo};
  
  
      foreach (@mistakes){
  
  
  $worksheet-&gt;AddCell( $_, "" ); 
  }          
  
   $template-&gt;SaveAs($infile2);`
  </code></pre>