對於用uno凍結窗口,我發現它只有在您用選項Hidden = False打開文檔時纔有效。當「隱藏」設置爲「真」時,不會應用凍結命令。
import uno
#function for setting parameters
def make_property_array(**kwargs):
"""convert the keyword arguments to a tuple of PropertyValue unostructures"""
array = []
for name, value in kwargs.iteritems():
prop = uno.createUnoStruct("com.sun.star.beans.PropertyValue")
prop.Name = name
prop.Value = value
array.append(prop)
return tuple(array)
#load the document
url = "file:///" + pathtoyourfile.replace("\\","/")
document = desktop.loadComponentFromURL(url, "_blank", 0, make_property_array(Hidden=False))
#set cell A1 as active
table.getCellByPosition(0,0)
#freeze the sheet at row 1
document.CurrentController.freezeAtPosition(0,1)
#save document in Excelformat
document.storeAsURL(url.replace("ods","xls"), make_property_array(FilterName="MS Excel 97", Overwrite=True))
請顯示最小代碼示例。 –
你在使用什麼操作系統?如果它是Windows,你是否擅長運行它? –