Pergunta

Discussão sobre ooooForum.org

Em Python, eu posso fazer algo assim:

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

Em C#, não consigo encontrar uma maneira de definir propriedades. O XTableTable possui apenas alguns métodos disponíveis, e nenhum deles parece fazer algo assim. Como faço para definir propriedades em C#?

Foi útil?

Solução

Você precisa acessar a tabela através da interface XPropertySet. Você pode fazer isso lançando a tabela para um 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)); 

O objeto "qualquer" está no espaço para nome "uno" (não unoidl.com.sun.star.uno). Você realmente não precisa fazer

typeof(int)

A menos que o tipo não seja um tipo básico.

new Any(1)

Funciona bem para tipos básicos.

Exemplo de BreakType:

XPropertySet tablePropertySet = (XPropertySet)table;
tablePropertySet.setPropertyValue
    ("BreakType", new Any(typeof(BreakType), BreakType.PAGE_BEFORE));
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top