Keep in mind I'm whipping this up on a PC that doesn't even have perl installed, never mind SS:WE. But I think this'll work.

If it looks like the code I posted for you yesterday, that's what I started from, since I don't have SS:WE's perldoc handy here.

#!/usr/bin/perl -w use strict; use Spreadsheet::WriteExcel; # don't need this here, but might in real script to get cell addresses #use Spreadsheet::WriteExcel::Utility; my $workbook=Spreadsheet::WriteExcel->new("test-counts.xls"); my $files_worksheet=$workbook->addworksheet("Files"); $files_worksheet->write(0,0,"Filename"); $files_worksheet->write(0,1,"ErrorType"); my %errorCodes; my %errorCodesByFile; my ($row, $col); # let's assume there's an input file, with data like # one.cxx 588 # one.cxx 588 # ... open(INFILE,"<errorList") or die "Can't open errorList, error $!"; $row=1; while(<INFILE>) { my ($file, $err)=split; $files_worksheet->write($row,0,$file); $files_worksheet->write($row,1,$err); # we need the list of ALL the errors, to get column headings $errorCodes{$err}++; # we need to COUNT how often each error occurs in each file $errorCodesByFile{$file}->{$err}++; ++$row; } close(INFILE); my $summ_worksheet=$workbook->addworksheet("Summary"); $summ_worksheet->write(0,0,"fileName"); $summ_worksheet->write(0,1,"Error"); my @sortedCodes = sort keys %errorCodes; $col=2; foreach my $errCode(@sortedCodes) { $summ_worksheet->write(0,$col++,$errCode); } $row=1; foreach my $filename(sort keys %errorCodesByFile) { $summ_worksheet->write($row,0,$fileName); $col=2; foreach my $errCode(@sortedCodes) { # set to blank if value 0 or not defined my $count=$errorCodesByFile{$file}->{$errCode} || ''; $summ_worksheet->write($row,$col++,$count); } ++$row; }
Hope this helps...
--
Mike

In reply to Re: WriteExcel by RMGir
in thread WriteExcel by amoura

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.