OpenOffice pyuno"全选"

c-u*_*hin 5 python openoffice.org uno pyuno openoffice-calc

有谁知道如何使用OO uno bridge api在Calc表中"全选"?

或者,找到最大使用的行和列号将起作用.

我想要做的是将格式应用于电子表格中的所有单元格.

(原因是我将工作表保存为csv,因此除非格式提供足够的小数位,否则数字不会准确保存.)

bku*_*lyk 2

假设您已经连接到 OpenOffice 并且document是已打开或创建的电子表格。

#get the sheet you want to work with, I'm just going to grab the first sheet
sheets = document.getSheets().createEnumeration()
sheet = sheets.nextElement()

#start with a range on the first cell
range = sheet.getCellRangeByPosition( 0, 0, 0, 0 )

#expand to full extend of the used area
range.gotoEndOfUsedArea( True ) #true for expand selection

#no do whatever formatting things you want to do
Run Code Online (Sandbox Code Playgroud)