使用OpenOffice的邮件合并 [英] Mailmerge using OpenOffice

查看:627
本文介绍了使用OpenOffice的邮件合并的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我想要做一个邮件合并,使用C#和OpenOffice。

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

我有destanatary在我的数据库列表。我想这是可能的:

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

  • 用户编辑面向对象的文档,把 像名,住址,城市领域 还有一些标准文本(如:你好 名称的你怎么样?,
  • 编辑风格,等等等等,
  • 然后进入我的应用程序,CLIC上 发送到所有的用户数据库。
  • 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".

然后该程序通过所有的用户环路,并为每个用户替换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.

问题:我找不到任何方式,在C#中,以取代DB数据的面向对象文档中的邮件合并领域,因为我找不到什么属性/方法处理这些领域。

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)

只有指针我发现,它似乎我需要的UNO库,但似乎它并没有在C#中存在。

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

推荐答案

在使用C#与OpenOffice的一般帮助:

General help on using C# with OpenOffice:

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

使用OO 3.0则需要参考CLI _ *。dll的图书馆,他们投入到GAC安装OO时。

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

一个样本code初始化OO连接:

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

加载文件:

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;

其中

 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的这里

另请参见<一个href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/OpenOffice.org_Developers_Guide"相对=nofollow> OpenOffice.org开发者指南。

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

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

希望这有助于

这篇关于使用OpenOffice的邮件合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆