Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: Copy paste rows in excel

by imrags (Monk)
on Jul 21, 2009 at 09:06 UTC ( #781893=note: print w/replies, xml ) Need Help??


in reply to Re^2: Copy paste rows in excel
in thread Copy paste rows in excel

As I said, think how you'll do it manually and make perl do it.
$Sheet->rows('4:4')->copy(); $Sheet->rows('15:15')->Select(); $Sheet->paste();
The above code copies 4th row cells to 15th row cells.
Raghu

Replies are listed 'Best First'.
Re^4: Copy paste rows in excel
by Anonymous Monk on Dec 29, 2016 at 13:45 UTC
    Hi I am trying the same code to copy values of one row of excel into another, but getting error "Can't locate object method "GetActiveObject" via package "Win32::OLE" (perhaps you forgot to load "Win32::OLE"?) at C:\Users\ssoni\Desktop\copyexcel.pl line 2." could you please help what should be done in the case?

      Without seeing the relevant parts of your source code, it's hard to give concrete advice.

      Have you loaded Win32::OLE as the error message suggests?

      use Win32::OLE;

      Also consider looking at the code in other replies here, like 781872, for getting a minimal example of what should work. Especially Using Win32::OLE and Excel - Tips and Tricks.

      Since this is line 2, I can't imagine well organised code including strictures and Win32::OLE in one line. I would bet that Corion has identified a part of your problem. Another, though, is that you are using GetActiveObject. Unless you have a really strong reason to do this (I can imagine a very few), always create your own instance of Excel. I outlined some reasons in Re: Win32-OLE: What is the canonical way to open file for editing?, but there are plenty more and precious few good reasons to take control of an instance of Excel opened for some other purpose.

      It's a good idea to create a SSCCE (https://web.archive.org/web/20160926072757/http://sscce.org) to show a problem and a solution. For eight examples, have a look at RFC Tutorial - Deleting Excel Rows, Columns and Sheets, where I show lots of code, each example being complete and opening an instance of Excel. Most of these open the Excel instance and book in the same way, but there are some minor variations. There may be other things there that you could usefully copy.

      Regards,

      John Davies

      Update: you might also like to look at the thread Inserting copied rows at another position in Excel, which contains SSCCEs.

Re^4: Copy paste rows in excel
by Ankit.11nov (Acolyte) on Jul 21, 2009 at 09:36 UTC
    Thanks again Raghu. Its working :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://781893]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2017-07-26 04:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (383 votes). Check out past polls.