On Wed, Feb 10, 2010 at 5:17 PM, nikunj badjatya <nikunjbadja...@gmail.com> wrote: > Hi, > I am using xlwt 0.7.2 and Python 2.6. > I come across a situation wherein one of the "rows" of the excel sheet > created was being overwritten. And it was flagging the following > error. > > File "/usr/local/lib/python2.6/site-packages/xlwt/Row.py", line 150, > in insert_cell > raise Exception(msg) > Exception: Attempt to overwrite cell > > *Action Taken:* > I commented out the "raise Exception" statement in Row.py library > module. > Here's the (line no. 150 ) of Row.py which i have edited: > > def insert_cell(self, col_index, cell_obj): > if col_index in self.__cells: > if not self.__parent._cell_overwrite_ok: > msg = "Attempt to overwrite cell: sheetname=%r rowx=%d > colx=%d" \ > % (self.__parent.name, self.__idx, col_index) > *#raise Exception(msg) > #########*commented to avoid error. * > prev_cell_obj = self.__cells[col_index] > sst_idx = getattr(prev_cell_obj, 'sst_idx', None) > if sst_idx is not None: > self.__parent_wb.del_str(sst_idx) > self.__cells[col_index] = cell_obj > > The excel sheet creation code now works fine. > > *My question is, Instead of manually goin to /usr/lib/.../row.py and > commenting out the line, Can this be done through few lines of code in > my program itself. ??* As in if I use my program on different system, > then again I have to comment out that line in row.py..!! > Any suggestions??
Try setting: worksheet._cell_overwrite_ok = True Looks like you can do that even when adding new sheets. sheet = workbook.add_sheet("foo", cell_overwrite_ok=True) Anand _______________________________________________ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers