Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

davies's scratchpad

by davies (Vicar)
on May 15, 2005 at 11:44 UTC ( #457204=scratchpad: print w/ replies, xml ) Need Help??

use strict; use warnings; use Win32::OLE; use SVG; my $xl = Win32::OLE->new('Excel.Application'); $xl->{ReferenceStyle} = 1; #xlA1 $xl->{Visible} = 1; my $sFileName = 'z:\data\perl\ladyaleena\darkenwood.xls'; my $wb = $xl->Workbooks->Open($sFileName) or die "Can't open file <$sF +ileName>: " . $!; my $sht = $wb->Sheets('House and Tower'); #my $sht = $wb->Sheets('Cave 1'); my $nMaxRow = $sht->UsedRange->Rows ->Count; my $nMaxCol = $sht->UsedRange->Columns->Count; my @nColWidths; my @nRowHeights; my @nColCumWidths; my @nRowCumHeights; $nColCumWidths [0] = 0; $nRowCumHeights[0] = 0; for my $nRow(1..$nMaxRow) { $nRowHeights [$nRow] = $sht->Cells($nRow, 1)->Height * 2; $nRowCumHeights[$nRow] = $nRowCumHeights[$nRow - 1] + $nRowHeights +[$nRow]; } for my $nCol(1..$nMaxCol) { $nColWidths [$nCol] = $sht->Cells(1, $nCol)->Width * 4; $nColCumWidths[$nCol] = $nColCumWidths[$nCol - 1] + $nColWidths[$n +Col]; } my $svg = SVG->new(width=>$nColCumWidths[$nMaxCol], height=>$nRowCumHe +ights[$nMaxRow]); for my $nRow(1..$nMaxRow) { for my $nCol(1..$nMaxCol) { my $cell = $sht->Cells($nRow, $nCol); my $dudColour = sprintf("%06x", $cell->Interior->PatternColor) +; my $goodColour = '#' . substr($dudColour, -2) . substr($dudCol +our, 2, 2) . substr($dudColour, 0, 2); my $tagRect = $svg->rectangle( x=>$nColCumWidths[$nCol - 1], y=>$nRowCumHeights[$nRow - 1 +], width=>$nColWidths[$nCol], height=>$nRowHeights[$nRow], fill=> $goodColour, id=>'R' . $nRow . 'C' . $nCol ); my $tagText = $svg->text( id=>'TxtR' . $nRow . 'C' . $nCol, x=>$nColCumWidths[$nCol - 1], y=>$nRowCumHeights[$nRow] )->cdata('R' . $nRow . 'C' . $nCol); } } open my $fh, ">", 'z:\data\perl\ladyaleena\Cave1.svg' or die $!; print $fh $svg->xmlify(); close $fh; $xl->Quit;
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2014-12-25 11:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (160 votes), past polls