T
T
technomaniak12015-06-09 11:05:43
Python
technomaniak1, 2015-06-09 11:05:43

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)

I generate an excel file in the above way. The cell styles are preserved, but the images are removed for some reason. Please tell me what is the problem.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2015-06-09
@technomaniak1

xlutils - can not do everything that excel can and copies it, respectively, only what it can. He doesn't know how to take pictures.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question