使用 OpenOffice 进行邮件合并

发布于 2024-07-29 08:04:22 字数 475 浏览 3 评论 0原文

我目前正在尝试使用 C# 和 OpenOffice 进行邮件合并。

我的数据库中有一个 destanatary 列表。 我希望这成为可能:

  • 用户编辑 OO 文档,将 “名称”“地址”“城市”等字段 和一些标准文本(例如:“你好 姓名你好吗?”,
  • 编辑样式等,
  • 然后转到我的应用程序,点击 “发送给数据库中的所有用户”。

然后程序循环遍历所有用户,并为每个用户用 DB 数据替换 OO 文档中的邮件合并字段,通过邮件/打印/其他方式发送。

问题: 在 C# 中,我找不到任何方法用 DB 数据替换 OO 文档中的邮件合并字段,因为我找不到处理这些字段的属性/方法。

请大家帮帮我,年终奖就靠它了! (原文如此)

我发现的唯一提示是我似乎需要 UNO 库,但 C# 中似乎不存在它。

I'm currently trying to do a mailmerge, using C# and OpenOffice.

I have a list of destanatary in my DB. I would like this to be possible :

  • the user edit an OO document, put
    fields like "name" "adresse" "city"
    and some standard text (e.g. : "Hello
    Name how are you ?",
  • edit the style, etc etc,
  • then go to my application, clic on
    "Send to all user in DB".

Then the program loops through all user, and for each user replace the mailmerge fields in the OO document with DB data's, send it by mail/print/whatever.

Problem : I can't find any way, in C#, to replace the mailmerge fields in the OO document with DB data's, because i can't find what Property/Method handle these fields.

Please help me by annual bonus depends on it ! (sic)

Only pointer I found was that it seems I'll need the UNO Library, but it seems it doesn't exist in C#.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无力看清 2024-08-05 08:04:22

有关在 OpenOffice 中使用 C# 的一般帮助:

http://www.oooforum.org/论坛/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");
 }

加载文档:

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;

where

 private static PropertyValue MakePropertyValue(string cName, Any uValue)
 {     
    PropertyValue oPropertyValue = new PropertyValue();
    if (!string.IsNullOrEmpty(cName))
       oPropertyValue.Name = cName;
    oPropertyValue.Value = uValue;
    return oPropertyValue;
 }

阅读有关我们可以做什么的更多信息 XTextDocument 此处

另请参阅 OpenOffice.org 开发人员指南

更新
另一个有用的链接:
http://blog.nkadesign .com/2008/net-working-with-openoffice-3/

希望这有帮助

General help on using C# with OpenOffice:

http://www.oooforum.org/forum/viewtopic.phtml?p=151606
http://opendocument4all.com/content/view/68/47/

With OO 3.0 you'll need to reference cli_*.dll libraries, they are put to GAC when OO is installed.

A sample code to initialize OO connection:

 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");
 }

Loading document:

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;

where

 private static PropertyValue MakePropertyValue(string cName, Any uValue)
 {     
    PropertyValue oPropertyValue = new PropertyValue();
    if (!string.IsNullOrEmpty(cName))
       oPropertyValue.Name = cName;
    oPropertyValue.Value = uValue;
    return oPropertyValue;
 }

Read more on what you can do we XTextDocument here.

See also OpenOffice.org Developer's guide.

UPDATE.
One more useful link:
http://blog.nkadesign.com/2008/net-working-with-openoffice-3/

Hope this helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文