excel - python xlwings - copy and paste ranges -


my first question on site.

i using xlwings python 2.7. want copy values in range 'a1:a6' sheet1 cells 'a1:a6' in sheet2. code follows:

> my_range = range('sheet1','a1:a6').value >  > range('sheet2','a1:a6').value = my_range 

when run code, however, puts values of my_range cells 'a1:f1' on sheet 2 instead of cells 'a1:a6' in sheet 2.

columns (as rows) returned simple ("horizontal") lists, see docs here. why? first of all, mimics behavior of numpy 1d arrays. second, it's you'll want, e.g. can directly iterate on column or check if value exists without having unpack nested list first.

now, in case, you'll want preserve 2d shape can (again similar numpy) follows:

my_values = range('sheet1','a1:a6', atleast_2d=true).value  range('sheet2','a1:a6').value = my_values 

also note call my_range should rather called my_values holds list, not xlwings range object.

update:

since v0.7.0, syntax changed to:

my_values = range('sheet1','a1:a6').options(ndim=2).value  range('sheet2','a1:a6').value = my_values 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -