Hi, <br> I am using xlwt 0.7.2 and Python 2.6. <br> I come across a situation wherein one of the "rows" of the excel sheet <br> created was being overwritten. And it was flagging the following <br> error. <br> <p>
<span style="background-color: rgb(51, 102, 255);">File "/usr/local/lib/python2.6/site-packages/xlwt/Row.py", line 150, </span><br style="background-color: rgb(51, 102, 255);"><span style="background-color: rgb(51, 102, 255);"> in insert_cell </span><br style="background-color: rgb(51, 102, 255);">
<span style="background-color: rgb(51, 102, 255);"> raise Exception(msg) </span><br style="background-color: rgb(51, 102, 255);"><span style="background-color: rgb(51, 102, 255);"> Exception: Attempt to overwrite cell </span><span style="background-color: rgb(255, 255, 0);"></span><span style="background-color: rgb(255, 255, 102);"></span><br>
</p><p><b>Action Taken:</b> <br> I commented out the "raise Exception" statement in Row.py library <br> module. <br> Here's the (line no. 150 ) of Row.py which i have edited: <br> </p><p> def insert_cell(self, col_index, cell_obj): <br>
if col_index in self.__cells: <br> if not self.__parent._cell_overwrite_ok: <br> msg = "Attempt to overwrite cell: sheetnam<span style="background-color: rgb(255, 255, 255);"></span>e=%r rowx=%d <br>
colx=%d" \ <br> % (self.__<a href="http://parent.name">parent.name</a>, self.__idx, col_index) <br> <b><span style="background-color: rgb(255, 0, 0);">#raise Exception(msg)</span> <br>
#########*commented to avoid error. </b><br> prev_cell_obj = self.__cells[col_index] <br> sst_idx = getattr(prev_cell_obj, 'sst_idx', None) <br> if sst_idx is not None: <br> self.__parent_wb.del_str(sst_idx) <br>
self.__cells[col_index] = cell_obj <br> </p><p>The excel sheet creation code now works fine. <br> </p><p><b>My question is, Instead of manually goin to /usr/lib/.../row.py and <br> commenting out the line, Can this be done through few lines of code in <br>
my program itself. ??</b> As in if I use my program on different system, <br> then again I have to comment out that line in row.py..!! <br> Any suggestions?? <br> </p>Thanks, <br> Nikunj <br> Bangalore, India