code:
use Spreadsheet::WriteExcel; my $token; my $file; my $del; my $wb; my $file = "coverage"; open (TXTFILE, "$file") or die; my $wb = Spreadsheet::WriteExcel->new("$file.xls"); my $coverage = $wb->addworksheet("coverage"); my $row = 2; my $col; $coverage->set_column( 0, 0, 25 ); $coverage->set_column( 1, 1, 25 ); $coverage->set_column( 2, 2, 25 ); $coverage->set_column( 3, 3, 25 ); $coverage->set_column( 4, 4, 25 ); my $format = $wb->add_format( color => 12, # index for blue font => 'Arial', size => 12, bold => 1, ); $coverage ->write(0, 0, "TARGET",$format); $coverage ->write(0, 1, "TOTAL_COMMANDS",$format); $coverage ->write(0, 2, "EXECUTABLE",$format); $coverage->write(0, 3, "NOT_EXECUTABLE",$format); $coverage ->write(0, 4, "COVERAGE",$format); my ($y,$x) = (0, 0); while (<TXTFILE>) { chomp; $del="\t"; my $row1 = 2; my $col1; my $row2 = 2; my $col2; my @Fld = split(/$del/, $_); $col = 0; my $coverage1 = $wb->addworksheet("$Fld[0]_execcutable"); my $coverage2 = $wb->addworksheet("$Fld[0]_not_execcutable"); my $format1 = $wb->add_format( color => 17, # index for blue font => 'Arial', size => 12, bold => 0, ); my $format2 = $wb->add_format( color => 10, # index for blue font => 'Arial', size => 12, bold => 0, ); open $file1 = "executable_$Fld[0]"; open $file2 = "not_executable_$Fld[0]"; open (EXEFILE, "$file1") or die; open NEXEFILE, $file2 or die"cannot open $file2 for read:$!"; foreach $token (@Fld) { $coverage->write($row, $col," \ $token\ " ); $col++; } while (<EXEFILE>){ $del1="\n"; $col1 = 0; my @Fld1 = split(/$del1/, $_); foreach $token1 (@Fld1) { $coverage1->write($row1, $col1," \ $token1\ ",$format1 ); $coverage1->write($row1, $col1," \ $token1\ ",$format1 ); $col1++; } $row1++; } while (<NEXEFILE>){ $del2="\n"; $col2 = 0; my @Fld2 = split(/$del2/, $_); foreach $token2 (@Fld2) { $coverage2->write($row2, $col2," \ $token2\ ",$format2 ); $coverage2->write($row2, $col2," \ $token2\ ",$format2 ); $col2++; } $row2++; } $row++; } close (NEXEFILE); close (EXEFILE); close (TXTFILE);

20080911 Janitored by Corion: Added code tags, as per Writeup Formatting Tips


In reply to Re^2: erron in spreadsheet::Write Excel by Anonymous Monk
in thread erron in spreadsheet::Write Excel by Anonymous Monk

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.