Answer the question
In order to leave comments, you need to log in
Why does xlwt remove pictures in xls file?
def _getOutCell(outSheet, colIndex, rowIndex):
""" HACK: Extract the internal xlwt cell representation. """
row = outSheet._Worksheet__rows.get(rowIndex)
if not row: return None
cell = row._Row__cells.get(colIndex)
return cell
def setOutCell(outSheet, col, row, value):
""" Change cell value without changing formatting. """
# HACK to retain cell style.
previousCell = _getOutCell(outSheet, col, row)
# END HACK, PART I
outSheet.write(row, col, value)
# HACK, PART II
if previousCell:
newCell = _getOutCell(outSheet, col, row)
if newCell:
newCell.xf_idx = previousCell.xf_idx
# END HACK
def x(request):
filename = os.path.join(settings.BASE_DIR, ' 123.xls')
rb = open_workbook(filename, on_demand = True, formatting_info = True)
w = copy(rb)
outSheet = w.get_sheet(0)
setOutCell( outSheet, 67, 44, 123 ) )
w.save(response)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question