1
我正在研究通過UNO與OpenOffice(swriter)交互的Java API。 對於TextTable,我很難設置TableColumn的「OptimalWidth」屬性。OpenOffice API - 用於表(所有列)的OptimalWidth選項
我試過下面的代碼,它似乎getColumns()方法不能帶我到TableColumn的屬性,讓你只能插入和刪除列。
XTableColumns xColumns = xTextTable.getColumns();
XIndexAccess xIndexAccess = (XIndexAccess) UnoRuntime.queryInterface(
XIndexAccess.class, xColumns);
for (int i = 0; i < xIndexAccess.getCount(); i++) {
XPropertySet xColumnProps = (XPropertySet) UnoRuntime
.queryInterface(XPropertySet.class,
(Any) xIndexAccess.getByIndex(i));
if (xColumnProps != null) {
xColumn.setPropertyValue("OptimalWidth", new Boolean(true));
}
}
任何人都可以幫我或給我任何提示設置表的OptimalWidth屬性? 非常感謝您提前!
我還沒有機會確認你的答案,但它看起來不錯。我會根據Miguel的回答接受你的回答,並在稍後檢查。謝謝! – 2011-02-16 20:26:04