Mac OS X:从数据库合并
我希望将(服务器)数据库中的几个自定义字段合并到字处理文档中,超出正常的“邮件合并”字段。我没有找到类似开箱即用的 API 之类的东西,可以让您对自定义字段执行此操作。这似乎在商业软件中很常见,但我认为这也是 Mac 在这方面表现不佳的又一个原因。
如果我要为此编写一个 Mac OS X/Objective-C/Cocoa 应用程序,那么最好的方法是在 RTF 文件中查找和替换字符串吗?也许在原始 RTF 中? 有没有更好的方法或格式来实现这一点?
I would like to have several custom fields from a (server) database merged into Word Processing documents, beyond the normal "mail merge" fields. I'm not finding anything like an API out of the box that allows you to do this for custom fields. This seems like it would be pretty common in business software, but I assume that's one more reason why the Mac doesn't excel there.
If I were to write a Mac OS X/Objective-C/Cocoa app for this, would the best way to approach it be finding and replacing strings in an RTF file? Maybe in the raw RTF?
Is there a better way or format to work with for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有专用的“邮件合并 API”并不是一个缺点——它必须过于具体才能成为一个普遍有用的 API。如果您更仔细地考虑这一点,就会发现没有足够抽象的案例来证明专用的内置 API 的合理性。大多数人想要“将 MySQL 数据库中的记录合并到 Word 文档中”或“将 Oracle 数据库中的记录合并到 PDF 文档中”。
不过,构建它的所有构建块都已存在,并且相对简单(伪代码):
要点:
hat there isn't a dedicated "mail merge API" isn't a detractor - it would have to be too specific to be generally useful enough to be an API. If you think about this more closely, there's no abstract-enough case to justify a dedicated, built-in API. Most people want to "merge records from a MySQL database into a Word document" or "merge records from an Oracle database into a PDF document".
All the building blocks are there to build it, though, and it's relatively simple (pseudocode):
Some points:
您可能想看看 Matt Gemmell 的 MGTemplateEngine ,因为它听起来就像它可能就是您正在寻找的一样。
You might want to check out Matt Gemmell's MGTemplateEngine as it sounds like it might be what you're looking for.