Changeset 2991


Ignore:
Timestamp:
2002-02-21T17:16:28+13:00 (22 years ago)
Author:
jrm21
Message:

Do MS Excel file processing, currently using a wrapper around xlhtml.

Location:
trunk/gsdl/bin/script
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/bin/script/gsConvert.pl

    r2977 r2991  
    6060    print STDERR "              or text using third-party programs.\n\n";
    6161    print STDERR "  usage: $0 [options] filename\n";
    62     print STDERR "  options:\n\t-type\tdoc|pdf|ps|ppt|rtf\t(input file type)\n";
     62    print STDERR "  options:\n\t-type\tdoc|pdf|ps|ppt|rtf|xls\t(input file type)\n";
    6363    print STDERR "\t-errlog\t<filename>\t(append err messages)\n";
    6464    print STDERR "\t-output\thtml|text\n";
     
    7777    # read command-line arguments
    7878    if (!parsargv::parse(\@ARGV,
    79              'type/(doc|pdf|ps|ppt|rtf)/', \$input_type,
     79             'type/(doc|pdf|ps|ppt|rtf|xls)/', \$input_type,
    8080             '/errlog/.*/', \$faillogfile,
    8181             'output/(html|text)/', \$output_type,
     
    136136    print "\n";
    137137    }
     138    elsif ($input_type eq "xls") {
     139    print &convertXLS($input_filename, $output_filestem, $output_type);
     140    print "\n";
     141    }
    138142    else {
    139143    print STDERR "Error: Unable to convert type '$input_type'\n";
     
    311315    if (system($cmd)!=0)
    312316    {
    313         print STDERR "Powerpoint converter failed $!\n";
     317        print STDERR "Powerpoint 95/97 converter failed $!\n";
     318    } else {
     319        return "html";
     320    }
     321    }
     322
     323    $success = &any_to_text($input_filename, $output_filestem);
     324    if ($success) {
     325    return "text";
     326    }
     327
     328    return "fail";
     329}
     330
     331
     332sub convertXLS {
     333    my ($input_filename, $output_filestem, $output_type) = @_;
     334
     335    my $success = 0;
     336
     337    # Attempt conversion to HTML
     338    if (!$output_type || ($output_type =~ /html/i)) {
     339    # formulate the command
     340    $cmd = "";
     341    $cmd .= "perl -S xlstohtml.pl ";
     342    $cmd .= " \"$input_filename\" \"$output_filestem.html\"";
     343    $cmd .= " 2>\"$output_filestem.err\""
     344        if ($ENV{'GSDLOS'} !~ /^windows$/i || $is_winnt_2000);
     345   
     346   
     347    # execute the command
     348    $!=0;
     349    if (system($cmd)!=0)
     350    {
     351        print STDERR "Excel 95/97 converter failed $!\n";
    314352    } else {
    315353        return "html";
Note: See TracChangeset for help on using the changeset viewer.