I used the following codes, but it doesn't work. I checked the xls. The formula is filled in correctly, but remains as a text entry. If to press ENTER to active this cell, it works.
sheet1.write(1, 1, xlwt.Formula('INDIRECT(\"\'sheet1\'!B1\")'))
I find INDIRECT is declared in xlwt\ExcelMagic.py:
all_funcs_by_name = {
# Includes Analysis ToolPak aka ATP aka add-in aka xcall functions,
# distinguished by -ve opcode.
# name: (opcode, min # args, max # args, func return type, func arg types)
# + in func arg types means 开发者_Python百科more of the same.
...
'INDIRECT' : (148, 1, 2, 'R', 'VV'),
...
Can anyone suggest how to use INDIRECT formula?
xlwt
has issues with compiling formulas that contain some functions that should return references. This doesn't matter in OpenOffice Calc and Gnumeric, which appear to operate on a "do what I mean" philosophy. In Excel 2003, you need to select the cell then hit F2 (forces it to decompile the formula from xlwt-generated bytecode to text) followed by Enter
(makes it compile the text into bytecode that it's happy with). Working on this is very low on my list of priorities.
精彩评论