Question

Discussion sur OOoForum.org

En python, je peux faire quelque chose comme ceci:

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

En C #, je ne peux pas trouver un moyen de définir les propriétés. XTableTable a seulement quelques méthodes dont elle dispose, et aucun d'entre eux ne semble rien faire comme ça. Comment puis-je définir les propriétés en C #?

Était-ce utile?

La solution

Vous devez accéder à la table via l'interface XPropertySet. Vous pouvez le faire en jetant la table à un 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)); 

Le « Tout » objet se trouve dans l'espace de noms « uno » (non unoidl.com.sun.star.uno). Vous avez vraiment pas besoin de faire

typeof(int)

sauf si le type n'est pas un type de base.

new Any(1)

fonctionne très bien pour les types de base.

Exemple de BREAKSaisissez:

XPropertySet tablePropertySet = (XPropertySet)table;
tablePropertySet.setPropertyValue
    ("BreakType", new Any(typeof(BreakType), BreakType.PAGE_BEFORE));
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top