SSIS导入Excel文件xls/xlsx
我需要将Excel文件中的信息导入到数据库中。 我有一个运行 ssis 包的网页,它获取一个 Excel 文件,并将数据加载到数据库中。
现在的问题在于,要处理 xls 或 xlxs 的不同类型的 excel 文件。
SSIS excel 连接管理器,允许您指定要连接到 xls 或 xlxs 的 excel 文件类型,您不能使用一个连接两种类型的管理器,现在只允许用户始终将 xlxs 文件更改为 xls,然后处理它,有没有一种方法可以根据 excel 文件的类型动态更改连接管理器, 或者当处理不同类型时,我应该只调用两个不同的 SSIS 包。
I have a requirement of importing information from an excel file to a database.
I have a webpage that runs an ssis package, that picks up an excel file, and loads data into a database.
The problem now lies, in the different types of excel files to be processes either xls or xlxs.
SSIS excel connection manager, lets you specify which type of excel file, you will be connecting to either xls or xlxs, you can not use one connection manager for both types, this now only allows the user to always change an xlxs file to xls, then process it, is there a way to dynamically change the connection manager, based on the type of excel file,
or should i just have two different SSIS packages called, when a different type is processed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 SSIS 2008 中,您可以设置与 2007 Excel 文件 (.xlsx) 的连接,然后使用连接管理器上的表达式将 ExcelFilePath 设置为变量的值。该变量的值可以是类型 97-2003 (.xls) 或 2007 (.xlsx),只要工作表名称相同,Excel 源就可以工作。
我不确定 SSIS 2005 中是否有相同的行为。
In SSIS 2008, you can set a Connection to a 2007 Excel file (.xlsx) and then use an Expression on the Connection Manager to set the ExcelFilePath to be the value of a variable. The value of this variable can be either type, 97-2003 (.xls) or 2007 (.xlsx) and the Excel Source will work, as long as the Sheet names are the same.
I'm not sure if this is the same behaviour in SSIS 2005.
如果您已经从代码运行 ssis 包,我想这应该相对容易做到。过去一周左右我一直在摆弄代码编辑包,修改变量等非常容易。我知道您还可以访问连接并指定 dtsConfig 文件
您可能有 2 个不同的配置文件,一个用于 xlsx并打开 xls 连接,并根据上传的 excel 文件扩展名使用适当的配置文件。
If you are running the ssis package from code already, I would imagine this should be relatively easy to do. I have been fiddling around with editing packages from code over the last week or so and it is pretty easy to modify variables etc. I know you can also access the connections and specify a dtsConfig file
You could potentially have 2 different config files one for xlsx and on for xls connections and use the appropriate config file based on the uploaded excel files extentsion.