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;
|