Cle*_*man 3 .net c# openoffice.org mailmerge
我目前正在尝试使用 C# 和 OpenOffice 进行邮件合并。
我的数据库中有一个 destanatary 列表。我希望这成为可能:
然后程序循环遍历所有用户,并为每个用户用 DB 数据替换 OO 文档中的邮件合并字段,通过邮件/打印/其他方式发送。
问题:在 C# 中,我找不到任何方法用 DB 数据替换 OO 文档中的邮件合并字段,因为我找不到处理这些字段的属性/方法。
请大家帮帮我,年终奖就靠它了!(原文如此)
我发现的唯一提示是我似乎需要 UNO 库,但 C# 中似乎不存在它。
将 C# 与 OpenOffice 结合使用的一般帮助:
http://www.oooforum.org/forum/viewtopic.phtml?p=151606 http://opendocument4all.com/content/view/68/47/
使用 OO 3.0,您需要引用 cli_*.dll 库,安装 OO 时会将它们放入 GAC。
初始化 OO 连接的示例代码:
private static XMultiServiceFactory _multiServiceFactory;
private static XComponentLoader _componentLoader;
private static XFileIdentifierConverter _urlConverter;
private static void Initialize()
{
XComponentContext localContext = uno.util.Bootstrap.bootstrap();
_multiServiceFactory = (XMultiServiceFactory)localContext.getServiceManager();
_componentLoader = (XComponentLoader)_multiServiceFactory.createInstance("com.sun.star.frame.Desktop");
_urlConverter = (XFileIdentifierConverter)_multiServiceFactory.createInstance("com.sun.star.ucb.FileContentProvider");
}
Run Code Online (Sandbox Code Playgroud)
加载文档:
string url = _urlConverter.getFileURLFromSystemPath(Path.GetPathRoot(path), path);
XComponent xComponent = _componentLoader.loadComponentFromURL(url, "_blank", 0, new PropertyValue[] { MakePropertyValue("Hidden", new uno.Any(true))});
XTextDocument doc = (XTextDocument)xComponent;
Run Code Online (Sandbox Code Playgroud)
在哪里
private static PropertyValue MakePropertyValue(string cName, Any uValue)
{
PropertyValue oPropertyValue = new PropertyValue();
if (!string.IsNullOrEmpty(cName))
oPropertyValue.Name = cName;
oPropertyValue.Value = uValue;
return oPropertyValue;
}
Run Code Online (Sandbox Code Playgroud)
请在此处阅读有关您可以通过 XTextDocument 执行哪些操作的更多信息。
更新。另一个有用的链接:
http://blog.nkadesign.com/2008/net-working-with-openoffice-3/
希望这可以帮助
| 归档时间: |
|
| 查看次数: |
3323 次 |
| 最近记录: |