Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

I am frustrated with WIN32::OLE

by padawan_linuxero (Scribe)
on Jan 15, 2008 at 05:53 UTC ( [id://662427]=perlquestion: print w/replies, xml ) Need Help??

padawan_linuxero has asked for the wisdom of the Perl Monks concerning the following question:

like the title said I am frustrated with WIN32::OLE
I just need to do simple stuff with perl but cant find it
I just need to empty rows at the beginning of the file from A1 and just add 16 rows!, another thing is how to save it!, the last thing is how to add the bmp file !, please I know this is not the way but I really need this code, can some one help me? , I am really need help.

Replies are listed 'Best First'.
Re: I am frustrated with WIN32::OLE
by Corion (Patriarch) on Jan 15, 2008 at 07:02 UTC
Re: I am frustrated with WIN32::OLE
by ady (Deacon) on Jan 15, 2008 at 07:03 UTC
    Remember, Google is your friend . . .

    Win32::OLE
    Search PerlMonks

    One small example :
    use Win32::OLE; # 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]->Qui +t;}) or die "Oops, cannot start Excel"; } # get a new workbook $book = $ex->Workbooks->Add; # write to a particular cell $sheet = $book->Worksheets(1); $sheet->Cells(1,1)->{Value} = "foo"; # write a 2 rows by 3 columns range $sheet->Range("A8:C9")->{Value} = [[ undef, 'Xyzzy', 'Plugh' ] +, [ 42, 'Perl', 3.1415 ] +]; # print "XyzzyPerl" $array = $sheet->Range("A8:C9")->{Value}; for (@$array) { for (@$_) { print defined($_) ? "$_|" : "<undef>|"; } print "\n"; } # save and exit $book->SaveAs( 'test.xls' ); undef $book; undef $ex;
    Best regards,
    Allan Dystrup
Re: I am frustrated with WIN32::OLE
by ArmandoG (Sexton) on Jan 15, 2008 at 16:10 UTC
    Guys!
    I have to agree with padawan, sometimes is very difficult to explain your needs when english is not the second language, but for what padawan ask is this, open a excel file (with data), then add "x" amount of rows at the beginning of the file, why all that space?, he needs to insert a pictures in BMP format, padawan for some of the same reason I quit the project here, but theres somethig I found it could be usefull its call VBScript Converter from ActiveState heres an example: after making a macro this come up
    Workbooks.Open Filename:="C:\Proyecto\csv\T3683.csv.xls" Rows("1:10").Select Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbov +e Range("B6").Select ActiveCell.FormulaR1C1 = "Report" Range("C7").Select
    Now I took that and put it into the VBScript and converted into this
    use Win32::OLE; use constant xlDown => -4121; use constant xlFormatFromLeftOrAbove => 0; my $_app_object = (Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application')); $_app_object->Workbooks->Open({Filename => 'C:\\Proyecto\\csv\\T3683.c +sv.xls'}); $_app_object->Rows('1:10')->Select(); $_app_object->Selection->Insert({Shift => xlDown, CopyOrigin => xlForm +atFromLeftOrAbove}); $_app_object->Range('B6')->Select(); $_app_object->ActiveCell->{FormulaR1C1} = 'Report'; $_app_object->Range('C7')->Select();
    Now One thing I could never find was Insert that is the command or instruction to insert rows??? Hope I could help and hope you could help thnaks

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://662427]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-25 20:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found