Guest User

Untitled

a guest
Oct 22nd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. use strict;
  2. use warnings;
  3.  
  4. use Spreadsheet::ParseExcel;
  5. use Spreadsheet::ParseExcel::SaveParser;
  6.  
  7. my $excel_file_name = $ARGV[0];
  8. my $parser = Spreadsheet::ParseExcel::SaveParser->new();
  9. my $workbook_orig = $parser->Parse($excel_file_name);
  10.  
  11. # We will edit column 7 of the first worksheet.
  12. my $worksheet = $workbook_orig->worksheet(0);
  13. my $EDIT_COL = 6;
  14.  
  15. my ($row_min, $row_max) = $worksheet->row_range();
  16. for my $r ($row_min .. $row_max){
  17. my $cell = $worksheet->get_cell($r, $EDIT_COL);
  18. unless (defined $cell){
  19. next; # Modify as needed to handle blank cells.
  20. }
  21. my $val = $cell->value . '_append_text';
  22. $worksheet->AddCell( $r, $EDIT_COL, $val, $cell->{FormatNo} );
  23. }
  24.  
  25. # You can save the modifications to the same file, but when
  26. # you are learning, it's safer to write to a different file.
  27. $excel_file_name =~ s/.xls$/_new.xls/;
  28. $workbook_orig->SaveAs($excel_file_name);
  29.  
  30. my $worksheet = $workbook_orig->worksheet(0);
Add Comment
Please, Sign In to add comment