如何将数据库中的值导入Excel目标列 [英] How to import values from database to excel destination column

查看:131
本文介绍了如何将数据库中的值导入Excel目标列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I am looking to export values from database directly to excel to particular column since remaining column as formulas in it.





我尝试了什么:



我希望将数据库中的值直接导出到excel到特定列,因为剩下的列为其中的公式。



What I have tried:

I am looking to export values from database directly to excel to particular column since remaining column as formulas in it.

推荐答案

通过 VBA 实现这一目标的最简单方法代码是:

1.创建 ADODB.Connection [ ^ ]能够连接到您的数据库

2.创建 ADODB.Recordset [< a href =https:// doc s.microsoft.com/en-us/sql/ado/reference/ado-api/recordset-object-ado?view=sql-server-2017\"target =_ blanktitle =新窗口> ^ ]打开它并获取/获取数据

3.使用 Range.CopyFromRecordset [ ^ ] Excel中的方法从记录集对象复制数据



在C#或VB.NET中 - 实现这一目标的方法是有点不同...



如果没有具体细节,我无法帮到你。
The simplest way to achieve that via VBA code is to:
1. Create ADODB.Connection[^] to be able to connect to your database
2. Create ADODB.Recordset[^] to open it and grab/fetch data into it
3. Use Range.CopyFromRecordset[^] method in Excel to copy data from recordset object

In C# or VB.NET - the way to achieve that is bit different...

Without specific details, i can't help you more.


这篇关于如何将数据库中的值导入Excel目标列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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