#!d:\perl\bin\perl.exe
use strict;
use Time::gmtime;
use CGI qw(:standard);
use Spreadsheet::ParseExcel;
my $excelFile='c:/inetpub/wwwroot/' . param('excelFile');
my $title=$excelFile;
my $oExcel = new Spreadsheet::ParseExcel;
my $oBook = $oExcel->Parse($excelFile);
my($iR, $iC, $oWkS, $oWkC);
printHeader();
printBody();
sub printSpreadsheet()
{
my $startpage = 0;
print "
FILE :", $oBook->{File} , "\n";
for(my $iSheet=0;
$iSheet < $oBook->{SheetCount} ;
$iSheet++) {
$oWkS = $oBook->{Worksheet}[$iSheet];
if($oBook->{SheetCount} gt 1)
{
print h1($oWkS->{Name});
}
print " \n";
for(my $iR = $oWkS->{MinRow} ;
defined $oWkS->{MaxRow} && $iR <= $oWkS->{MaxRow} ; $iR++) {
print "\n";
for(my $iC = $oWkS->{MinCol} ;
defined $oWkS->{MaxCol} && $iC <= $oWkS->{MaxCol} ;
$iC++) {
$oWkC = $oWkS->{Cells}[$iR][$iC];
if($oWkC)
{
print "ColorIdxToRGB($oWkC->{Format}->{Fill}[1]),"\'>\n";
if ($iR eq 0 or $iC eq 0)
{
print "";
}
if ($oWkC->Value ne '')
{
print toHtml($oWkC->Value), "\n";
}
else
{
print " ";
}
if($iC == 2 && $iR gt 1)
{
print "";
}
print " \n";
}
else
{
print " \n";
}
}
print " \n";
}
print "
\n";
}
}
#########################################################
sub printHeader
{
print "Content-type:text/html\n\n";
print "\n";
print "", $title, " ";
print " \n";
print "\n";
print "\n";
print "\n";
}
#########################################################
sub printBody()
{
printSpreadsheet();
print "x\n";
print "\n";
}
#########################################################
sub toHtml()
{
local ($_) = @_;
s/&/&/g;
s/>/>/g;
s/</g;
# etc...
return $_;
}