我正在用 C# 创建一个 OO Writer 文档。
任何帮助将不胜感激 - 我不再知道我是来还是去,我尝试了很多变化......
使用 C#,有没有人成功完成以下工作?我只有一个包含 2 列的简单表格,并且想将列宽设置为不同的值(此阶段的实际值无关紧要 - 只是宽度不同)。
此代码改编自各种 Web 资源,作为如何处理列宽的示例。我无法让它工作....
//For OpenOffice....
using unoidl.com.sun.star.lang;
using unoidl.com.sun.star.uno;
using unoidl.com.sun.star.bridge;
using unoidl.com.sun.star.frame;
using unoidl.com.sun.star.text;
using unoidl.com.sun.star.beans;
..............................
XTextTable odtTbl = (XTextTable) ((XMultiServiceFactory)oodt).createInstance("com.sun.star.text.TextTable");
odtTbl.initialize(10, 2);
XPropertySet xPS = (XPropertySet)odtTbl;
Object xObj = xPS.getPropertyValue("TableColumnSeparators")**; // << Runtime ERROR**
TableColumnSeparator[] xSeparators = (TableColumnSeparator[])xObj;
xSeparators[0].Position = 500;
xSeparators[1].Position = 5000;
xPS.setPropertyValue("TableColumnSeparators", new uno.Any(typeof(unoidl.com.sun.star.text.XTextTable),xSeparators));
// Runtime ERROR indicates the ; at the end of the Object line, with message of IllegalArgumentException
现在,这只是所有尝试组合中的一种错误。根本没有多少允许执行,但上面的代码确实一直运行到出现错误。
请问在 C# 中执行此操作的正确代码是什么?
此外,将 O'Writer 标题设置为特定样式(例如“标题 1”)以使其在文档中看起来和打印出该样式的正确 C# 代码是什么?
谢谢你。