¿Cómo configura las propiedades para un XTextTable en OpenOffice.org Uno usando C#?
-
22-09-2019 - |
Pregunta
En Python, puedo hacer algo como esto:
table.BreakType = PAGE_BEFORE
table.HoriOrient = 0
table.RightMargin = 6.93 * 2540 - table_width
En C#, no puedo encontrar una manera de establecer propiedades. Xtableable solo tiene algunos métodos disponibles, y ninguno de ellos parece hacer algo así. ¿Cómo configuro las propiedades en C#?
Solución
Debe acceder a la tabla a través de la interfaz XPropertySet. Puedes hacer esto lanzando la mesa a 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));
El objeto "Any" está en el espacio de nombres "UNO" (no unoidl.com.sun.star.uno). Realmente no necesitas hacer
typeof(int)
A menos que el tipo no sea un tipo básico.
new Any(1)
Funciona bien para los tipos básicos.
Ejemplo de breaktype:
XPropertySet tablePropertySet = (XPropertySet)table;
tablePropertySet.setPropertyValue
("BreakType", new Any(typeof(BreakType), BreakType.PAGE_BEFORE));
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow