views:

204

answers:

1

Discussion on OOoForum.org

In python, I can do something like this:

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

In C#, I can't find a way to set properties. XTableTable only has a few methods available to it, and none of them seem to do anything like this. How do I set properties in C#?

A: 

You have to access the table through the XPropertySet interface. You can do this by casting the table to an 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));

The "Any" object is in the "uno" namespace (not unoidl.com.sun.star.uno). You don't really need to do

typeof(int)

unless the type isn't a basic type.

new Any(1)

works fine for basic types.

BreakType example:

XPropertySet tablePropertySet = (XPropertySet)table;
tablePropertySet.setPropertyValue
    ("BreakType", new Any(typeof(BreakType), BreakType.PAGE_BEFORE));
Matthew