How I can open an existing csv file with Excel 2000,add colomns and run a formula on those columns using a perl script.I am trying a test script by which I am able to open an excel file but I am not able to open a csv file.
Below is the script
useWin32::OLE;
use Win32::OLE::Const;
my $wd = Win32::OLE::Const->Load(“Microsoft Excel 8.0 Object Library”);
# use existing instance if Excel is already running
eval {$ex = Win32::OLE->GetActiveObject(‘Excel.Application’)};
die “Excel not installed” if $@;
unless (defined $ex) {
$ex = Win32::OLE->new(‘Excel.Application’, sub {$_[0]->Quit;})
or die “Oops, cannot start Excel”;
}
$time = localtime;
# open a workbook, activate the first sheet and write header
$book = $ex->Workbooks->Open( ‘test.csv’ );
$sheet = $book->Worksheets(sheet2);
$sheet->Cells(1,1)->{Value} = “Spool Files Deleted by Date”
If there are any ideas how to convert an execel file run an macro add columns and then save it as csv those are also welcome asthese can be done with a single perl script.
As far as I know perl cannot save into csv format so I am converting the file manually to csv then trying to modify it.