2 回答

TA贡献1798条经验 获得超3个赞
您需要将单元格属性设置为更改后的边框对象。
aThinBorder = oRange.TopBorder2 aThinBorder.LineWidth = 1 oRange.TopBorder2 = aThinBorder

TA贡献1872条经验 获得超3个赞
因此,经过大量研究后,我找到了至少三种更改边框设置的方法。因为我花了很多精力,所以我想我应该把它们留在这里,这样将来其他人可能会更容易找到答案。
在所有示例中,我将单个单元格的 TopBorder 的 LineWidth 设置为 10。
方法 1:使用 getPropertyValue() 和 setPropertyValue()
cell = active_sheet.getCellByPosition(1, 1)
border_prop = cell.getPropertyValue("TopBorder")
border_prop.LineWidth = 10
cell.setPropertyValue("TopBorder", border_prop)
方法2(源自Jim K的回答)
cell = active_sheet.getCellByPosition(1, 1)
border_prop = cell.TopBorder2
border_prop.LineWidth = 10
cell.TopBorder2 = border_prop
方法 3:使用 BorderLine2 结构体
border_prop = uno.createUnoStruct("com.sun.star.table.BorderLine2")
border_prop.LineWidth = 10
cell = active_sheet.getCellByPosition(1, 1)
cell.setPropertyValue("TopBorder", border_prop)
添加回答
举报