<?xml version="1.0" encoding="windows-1252"?>
<node id="457204" title="davies's scratchpad" created="2005-05-15 07:44:12" updated="2005-08-11 10:33:02">
<type id="182711">
scratchpad</type>
<author id="436161">
davies</author>
<data>
<field name="doctext">
&lt;c&gt;use strict;
use warnings;
use Win32::OLE;
use SVG;

my $xl = Win32::OLE-&gt;new('Excel.Application');
$xl-&gt;{ReferenceStyle} = 1;	#xlA1
$xl-&gt;{Visible}        = 1;
my $sFileName = 'z:\data\perl\ladyaleena\darkenwood.xls';
my $wb = $xl-&gt;Workbooks-&gt;Open($sFileName) or die "Can't open file &lt;$sFileName&gt;: " . $!;
my $sht = $wb-&gt;Sheets('House and Tower');
#my $sht = $wb-&gt;Sheets('Cave 1');
my $nMaxRow = $sht-&gt;UsedRange-&gt;Rows   -&gt;Count;
my $nMaxCol = $sht-&gt;UsedRange-&gt;Columns-&gt;Count;
my @nColWidths;
my @nRowHeights;
my @nColCumWidths;
my @nRowCumHeights;
$nColCumWidths [0] = 0;
$nRowCumHeights[0] = 0;

for my $nRow(1..$nMaxRow) {
    $nRowHeights   [$nRow] = $sht-&gt;Cells($nRow, 1)-&gt;Height * 2;
    $nRowCumHeights[$nRow] = $nRowCumHeights[$nRow - 1] + $nRowHeights[$nRow];
}

for my $nCol(1..$nMaxCol) {
    $nColWidths   [$nCol] = $sht-&gt;Cells(1, $nCol)-&gt;Width * 4;
    $nColCumWidths[$nCol] = $nColCumWidths[$nCol - 1] + $nColWidths[$nCol];
}

my $svg = SVG-&gt;new(width=&gt;$nColCumWidths[$nMaxCol], height=&gt;$nRowCumHeights[$nMaxRow]);

for my $nRow(1..$nMaxRow) {
    for my $nCol(1..$nMaxCol) {
        my $cell = $sht-&gt;Cells($nRow, $nCol);
        my $dudColour = sprintf("%06x", $cell-&gt;Interior-&gt;PatternColor);
        my $goodColour = '#' . substr($dudColour, -2) . substr($dudColour, 2, 2) . substr($dudColour, 0, 2);
        my $tagRect = $svg-&gt;rectangle(
            x=&gt;$nColCumWidths[$nCol - 1], y=&gt;$nRowCumHeights[$nRow - 1],
            width=&gt;$nColWidths[$nCol], height=&gt;$nRowHeights[$nRow],
            fill=&gt; $goodColour,
            id=&gt;'R' . $nRow . 'C' . $nCol
        );
        my $tagText = $svg-&gt;text(
            id=&gt;'TxtR' . $nRow . 'C' . $nCol,
            x=&gt;$nColCumWidths[$nCol - 1], y=&gt;$nRowCumHeights[$nRow]
        )-&gt;cdata('R' . $nRow . 'C' . $nCol);
    }
}

open my $fh, "&gt;", 'z:\data\perl\ladyaleena\Cave1.svg' or die $!;
print $fh $svg-&gt;xmlify();
close $fh;
$xl-&gt;Quit;&lt;/c&gt;</field>
</data>
</node>
