Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
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 lurking in the Monastery: (14)
As of 2015-07-02 11:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (34 votes), past polls