From: pp on
Whenever i run the code below I get the following error:

AttributeError: 'Book' object has no attribute 'on_demand'
WARNING: Failure executing file: <copy.py>

Why is it so??

from xlrd import open_workbook
from xlwt import easyxf
from xlutils.copy import copy
rb = open_workbook('source.xls',formatting_info=True)
rs = rb.sheet_by_index(0)
wb = copy(rb)
ws = wb.get_sheet(0)
plain = easyxf('')
for i,cell in enumerate(rs.col(2)):
if not i:
continue
ws.write(i,2,cell.value,plain)
for i,cell in enumerate(rs.col(4)):
if not i:
continue
ws.write(i,4,cell.value-1000)
wb.save('output.xls')

From: Jon Clements on
On Jan 9, 10:24 am, pp <parul.pande...(a)gmail.com> wrote:
> Whenever i run the code below I get the following error:
>
> AttributeError: 'Book' object has no attribute 'on_demand'
> WARNING: Failure executing file: <copy.py>
>
> Why is it so??
>
> from xlrd import open_workbook
> from xlwt import easyxf
> from xlutils.copy import copy
> rb =  open_workbook('source.xls',formatting_info=True)
> rs =  rb.sheet_by_index(0)
> wb =  copy(rb)
> ws =  wb.get_sheet(0)
> plain = easyxf('')
> for i,cell in enumerate(rs.col(2)):
>      if not i:
>          continue
>      ws.write(i,2,cell.value,plain)
> for i,cell in enumerate(rs.col(4)):
>      if not i:
>          continue
>      ws.write(i,4,cell.value-1000)
> wb.save('output.xls')

I suspect your version of xlrd is not up to date (although I thought
on_demand was ages ago!).
Make sure all the tools are the latest versions from http://www.python-excel.org

There's also a dedicated Google Group for the xl* products listed on
that page.

hth
Jon.

From: pp on
On Jan 9, 3:42 am, Jon Clements <jon...(a)googlemail.com> wrote:
> On Jan 9, 10:24 am, pp <parul.pande...(a)gmail.com> wrote:
>
>
>
> > Whenever i run the code below I get the following error:
>
> > AttributeError: 'Book' object has no attribute 'on_demand'
> > WARNING: Failure executing file: <copy.py>
>
> > Why is it so??
>
> > from xlrd import open_workbook
> > from xlwt import easyxf
> > from xlutils.copy import copy
> > rb =  open_workbook('source.xls',formatting_info=True)
> > rs =  rb.sheet_by_index(0)
> > wb =  copy(rb)
> > ws =  wb.get_sheet(0)
> > plain = easyxf('')
> > for i,cell in enumerate(rs.col(2)):
> >      if not i:
> >          continue
> >      ws.write(i,2,cell.value,plain)
> > for i,cell in enumerate(rs.col(4)):
> >      if not i:
> >          continue
> >      ws.write(i,4,cell.value-1000)
> > wb.save('output.xls')
>
> I suspect your version of xlrd is not up to date (although I thought
> on_demand was ages ago!).
> Make sure all the tools are the latest versions fromhttp://www.python-excel.org
>
> There's also a dedicated Google Group for the xl* products listed on
> that page.
>
> hth
> Jon.

yeah all my versions are latest from http://www.python-excel.org .
just checked!!
what could be the problem?
From: Jon Clements on
On Jan 9, 10:44 am, pp <parul.pande...(a)gmail.com> wrote:
> On Jan 9, 3:42 am, Jon Clements <jon...(a)googlemail.com> wrote:
>
>
>
> > On Jan 9, 10:24 am, pp <parul.pande...(a)gmail.com> wrote:
>
> > > Whenever i run the code below I get the following error:
>
> > > AttributeError: 'Book' object has no attribute 'on_demand'
> > > WARNING: Failure executing file: <copy.py>
>
> > > Why is it so??
>
> > > from xlrd import open_workbook
> > > from xlwt import easyxf
> > > from xlutils.copy import copy
> > > rb =  open_workbook('source.xls',formatting_info=True)
> > > rs =  rb.sheet_by_index(0)
> > > wb =  copy(rb)
> > > ws =  wb.get_sheet(0)
> > > plain = easyxf('')
> > > for i,cell in enumerate(rs.col(2)):
> > >      if not i:
> > >          continue
> > >      ws.write(i,2,cell.value,plain)
> > > for i,cell in enumerate(rs.col(4)):
> > >      if not i:
> > >          continue
> > >      ws.write(i,4,cell.value-1000)
> > > wb.save('output.xls')
>
> > I suspect your version of xlrd is not up to date (although I thought
> > on_demand was ages ago!).
> > Make sure all the tools are the latest versions fromhttp://www.python-excel.org
>
> > There's also a dedicated Google Group for the xl* products listed on
> > that page.
>
> > hth
> > Jon.
>
> yeah all my versions are latest fromhttp://www.python-excel.org.
> just checked!!
> what could be the problem?

Does rb = xlrd.open_workbook('somesheet.xls', on_demand=True) work by
itself?
From: pp on
On Jan 9, 3:52 am, Jon Clements <jon...(a)googlemail.com> wrote:
> On Jan 9, 10:44 am, pp <parul.pande...(a)gmail.com> wrote:
>
>
>
> > On Jan 9, 3:42 am, Jon Clements <jon...(a)googlemail.com> wrote:
>
> > > On Jan 9, 10:24 am, pp <parul.pande...(a)gmail.com> wrote:
>
> > > > Whenever i run the code below I get the following error:
>
> > > > AttributeError: 'Book' object has no attribute 'on_demand'
> > > > WARNING: Failure executing file: <copy.py>
>
> > > > Why is it so??
>
> > > > from xlrd import open_workbook
> > > > from xlwt import easyxf
> > > > from xlutils.copy import copy
> > > > rb =  open_workbook('source.xls',formatting_info=True)
> > > > rs =  rb.sheet_by_index(0)
> > > > wb =  copy(rb)
> > > > ws =  wb.get_sheet(0)
> > > > plain = easyxf('')
> > > > for i,cell in enumerate(rs.col(2)):
> > > >      if not i:
> > > >          continue
> > > >      ws.write(i,2,cell.value,plain)
> > > > for i,cell in enumerate(rs.col(4)):
> > > >      if not i:
> > > >          continue
> > > >      ws.write(i,4,cell.value-1000)
> > > > wb.save('output.xls')
>
> > > I suspect your version of xlrd is not up to date (although I thought
> > > on_demand was ages ago!).
> > > Make sure all the tools are the latest versions fromhttp://www.python-excel.org
>
> > > There's also a dedicated Google Group for the xl* products listed on
> > > that page.
>
> > > hth
> > > Jon.
>
> > yeah all my versions are latest fromhttp://www.python-excel.org.
> > just checked!!
> > what could be the problem?
>
> Does rb = xlrd.open_workbook('somesheet.xls', on_demand=True) work by
> itself?

Yes it does. The problem is with line: wb = copy(rb)
here I am getting the error: AttributeError: 'Book' object has no
attribute 'on_demand'
Thanks ..
 |  Next  |  Last
Pages: 1 2
Prev: Append to an Excel file
Next: Something More Elegant