in reply to CGI & Spreadsheet::WriteExcel Module Help needed

You can always muck with Excel using Win32::OLE (aka COMTM) Recently I wrote the following, relatively simple, script to convert an ExcelTM file to TSV. For you I quickly swapped a few things around to convert TSV back to ExcelTM format. It worked for my simple testing. Note that the filename needs to be fully qualified or ExcelTM evilly thinks you mean it's default directory, not your current working directory.
#!perl -w use strict; use Win32::OLE; use Win32::OLE::Const 'Microsoft Excel'; $Win32::OLE::Warn = 2; # Always warn with verbose error messages # Open a new excel app, thus not stepping on anyones toes. my $Excel = Win32::OLE->new('Excel.Application', 'Quit') or die "Unable to start Excel"; # Set Application Visibility # 0 = Not Visible 1 = Visible $Excel->{Visible} = 0; my $file = 'c:\test.txt'; # I tested with a TSV file. die "'$file' not found" unless -e $file; my $new_file = $file; $new_file =~ s/txt$/xls/i; if( -e $new_file ) { my $n = 4; while( --$n ) { print STDERR "Deleting '$new_file' in $n seconds \r"; sleep 1; } warn "Deleting '$new_file' \n"; unlink $new_file; } my $Book = $Excel->Workbooks->Open($file); # Open the book. # And save it in the prefered format. $Book->SaveAs( { FileName => $new_file, FileFormat => xlNormal, # To save as TSV use xlText CreateBackup => 0} ); $Book->Close(0); $Excel->Quit();

Replies are listed 'Best First'.
RE: RE: CGI & Spreadsheet::WriteExcel Module Help needed
by elwarren (Priest) on Nov 03, 2000 at 19:18 UTC
    He's running a cgi script from the server. So unless he's running PerlScript enabled in the browser he won't be able to do OLE.