Excel/VBA 连接到 Oracle 数据库
我正在 VBA 中编写一个 Excel 2007 宏,该宏根据某些用户输入查询 Oracle 数据库。当我记录查询的宏时,该宏使用ListObjects.Add。但我知道还有 QueryTables 对象等。我正在寻找一个可以使手动编码变得最简单的对象,即代码将干净、简洁且有意义。此外,我不能简单地记录宏,因为查询是可变的 - 它取决于用户输入。
Excel 对象模型参考(MSDN 库中)中用于此目的的最佳对象(ListObjects、QueryTables 等)是什么?更一般地说,最好的方法是什么?
提前致谢。
I am writing an Excel 2007 macro in VBA that queries an Oracle database based on some user input. When I record a macro of the query, the macro uses ListObjects.Add. But I know there is also the QueryTables object, among other things. I am looking for an object that will make the hand-coding easiest, i.e. the code will be clean and concise, and make sense. Furthermore, I can't simply record a macro, because the query is variable - it is dependent on user input.
What is the best object (ListObjects, QueryTables, etc.) from the Excel Object Model Reference (in the MSDN Library) to use for this purpose? More generally, what is the best way to go about it?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我继续使用 QueryTables,它记录在 MSDN 库的 Excel 模型对象参考下。它干净、简单、直接。
I have gone ahead with QueryTables, which is documented in the MSDN Library under Excel Model Object Reference. It is clean, simple, and direct.