0

OOoForum.org 上的讨论

在 python 中,我可以这样做:

table.BreakType = PAGE_BEFORE
table.HoriOrient = 0
table.RightMargin = 6.93 * 2540 - table_width

在 C# 中,我找不到设置属性的方法。XTableTable 只有几个可用的方法,而且它们似乎都没有做这样的事情。如何在 C# 中设置属性?

4

1 回答 1

0

您必须通过 XPropertySet 接口访问该表。您可以通过将表转换为 XPropertSet 来做到这一点:

// Example 
XPropertySet tablePropSet = (XPropertySet)textTable; 

// This is how you set a property in C# 
// You have to create a new Any object to pass it as parameter 
tablePropSet.setPropertyValue("HeaderRowCount", new Any(typeof(int), 1)); 

“Any”对象位于“uno”命名空间(不是 unoidl.com.sun.star.uno)。你真的不需要做

typeof(int)

除非该类型不是基本类型。

new Any(1)

适用于基本类型。

BreakType 示例:

XPropertySet tablePropertySet = (XPropertySet)table;
tablePropertySet.setPropertyValue
    ("BreakType", new Any(typeof(BreakType), BreakType.PAGE_BEFORE));
于 2009-10-23T02:23:54.350 回答