From uhog.mit.edu!news.mathworks.com!gatech!hubcap.clemson.edu!usenet 27 Feb 1996 19:17:12 GMT
Path: uhog.mit.edu!news.mathworks.com!gatech!hubcap.clemson.edu!usenet
From: Barry Johnson  <cyclist@clancy.clemson.edu>
Newsgroups: comp.lang.perl.misc
Subject: dif2html - Spreadsheets to HTML tables
Date: 27 Feb 1996 19:17:12 GMT
Organization: Clemson University
Lines: 61
Message-ID: <4gvlbp$7e6@hubcap.clemson.edu>
NNTP-Posting-Host: beluga.clemson.edu
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 1.1N (Macintosh; I; 68K)
X-URL: news:comp.lang.perl.misc


I whipped this one up the other day for a project and thought
that someone out here might be able to use it.  It takes
DIF files (which most spreadsheets can output) from stdin and 
converts them to html tables.  If you are using  MacPerl it
works drag-n-drop!  


Let me know if it helped you!  Thanks...

Barry....

cut here-----------------------

# dif2html
#
# Author:  Barry Johnson, cyclist@clemson.edu
# Webmaster, Clemson University, 1996
#
# Distribute Freely with this header intact.
#
# This is a simple script that takes as standard input a file 
in DIF format
# and spits a corresponding html table.  Since most 
spreadsheets can export in a DIF
# format, I thought it might be rather useful.  Thanks....


open(OUTFILE,">$ARGV[0].html");  
print OUTFILE "<TABLE BORDER=5>\n";
$START = 0;
while (<>) {
    
    if (/^BOT/) { $START=1; print OUTFILE "<TR ALIGN=MIDDLE> 
\n";}
    
    if ((/^-1/) && ($START == 1)) { print OUTFILE "</TR>\n";}
    
    if (($START == 1) && (/^\"/)) {
          chop;
          if ( $_ eq '""') { print OUTFILE "<TD> </TD>\n";}
          else {
          s/\"//g;
          print OUTFILE "<TD><FONT SIZE=1>$_</FONT></TD>\n";}
       }
    if (($START == 1) && (/^0/))  {
          ($fodder,$data) = split(',',$_);
          print OUTFILE "<TD><FONT 
SIZE=1>$data</FONT></TD>\n";
       }
       
}
print OUTFILE "</TABLE>\n";
close(INFILE);
close(OUTFILE);       

cut here-----------------------

       



