
iphone
User
Aug 19, 2010, 12:33 PM
Post #6 of 23
(1652 views)
|
|
Re: [BillKSmith] Moving around lines in a file
[In reply to]
|
Can't Post
|
|
Sorry about not being clear,I manipulated the below code and adjusted to my requirement. I have one last question. print $cr_line, $_; -->Instead of printing,can you please help in putting this data in an excel sheet? Found this on google,trying this manipulate this with difficulty
use Win32::OLE; $file = "C:\\temp\\MyTest.xls"; $excel = Win32::OLE->GetActiveObject('Excel.Application'); unless($excel) { $excel = new Win32::OLE('Excel.Application', \&QuitApp) or die "Could not create Excel Application object"; } $excel->{Visible} = 1; $excel->{SheetsInNewWorkBook} = 1; $workbook = $excel->Workbooks->Add(); $worksheet = $workbook->Worksheets(1); $worksheet->{Name} = "Directory listing"; @files = glob('*'); $range=$worksheet->Range('A1:C1'); $range->{Value} = ['Filename', 'Size', 'Time']; my $cellrow = 2; foreach $file (@files) { my ($size,$mtime) = (stat($file))[7,9]; $range=$worksheet->Range(sprintf("%s%d:%s%d",'A',$cellrow,'C',$cellrow)); $range->{Value} = [$file,$size,scalar localtime $mtime]; $cellrow++; } $workbook->SaveAs($file); sub QuitApp { my ($object) = @_; $object->Quit(); }
|