将 Excel 工作表保存到 SQL 中
Excel 在“数据”选项卡中有一个“获取外部数据”功能区栏,我们可以在其中选择从 SQL 数据库导入表。这个过程对我来说效果很好。但我的问题是,有什么办法可以将这些数据保存回 SQL 中吗? Excel 是否提供了一些 API 来促进此类函数的编码,而无需解析所有内容并从头开始执行?
谢谢
Excel has a Get External Data ribbon bar in the Data tab where we can choose to import tables from SQL databases. This process worked out nicely for me. But my question is, is there any way to save this data back into SQL? Does Excel provide some API that facilitates the coding of such a function without parsing everything and doing it from scratch?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它可能不是您正在寻找的解决方案,但我很久以前发布了一些 VBA 代码,它将获取 Excel 中的范围并将其转换为 XML 并构建 SQL 以将该数据放入 SQL Server 中的临时表中。如果您有兴趣,这里有一个链接。
It may not be the solution you are looking for, but I posted some VBA code a long while back that will take a range in Excel and convert it to XML and builds the SQL to put that data into a temp table in SQL Server. Here's a link if you are interested.
最简单的方法是使用 SSMS 中的导入功能。您可以选择要使用的工作表、自定义列映射等。如果创建一个 SSIS,您可以根据需要进一步操作。然而,这种方法是从 Sql 拉取的,而不是从 Excel 推取的,如果你想这样做,你必须编写一些 VBA 来为你完成它。
The easiest way to do this is to use the import function within SSMS. You can select which sheets to use, customise column mappings and so on. If creates an SSIS that you can then manipulate further if required. However that approach is a pull from Sql, not a push from Excel, if you want to do that you'd have to code some VBA to do it for you.
非编程方式:
http://office.microsoft.com/en-us/excel-help/connect-to-import-sql-server-data-HA010217956.aspx
以编程方式-我只能想到MSSQL中的OpenRowSet函数:
http://www.mssqltips.com/tip.asp?tip=1540
http://www.sql-server -helper.com/tips/read-import-excel-file-p01.aspx
使用 openrowset 将 Excel 文件读入临时表;我如何引用该表?
Non-programmatically:
http://office.microsoft.com/en-us/excel-help/connect-to-import-sql-server-data-HA010217956.aspx
Programmatically - I can only think of the OpenRowSet function in MSSQL:
http://www.mssqltips.com/tip.asp?tip=1540
http://www.sql-server-helper.com/tips/read-import-excel-file-p01.aspx
Using openrowset to read an Excel file into a temp table; how do I reference that table?