简体   繁体   English

在Azure中将Excel文件导入到SQL Azure

[英]Import Excel files to SQL Azure, within Azure

I have read questions like this (Is Jet.OLEDB supported in 64bit?) and this (requires on-premise MSSQL) in SSO, but I have not come across the right solution that suits me. 我看过这样的问题 (是Jet.OLEDB在64位的支持?)和 (需要预置MSSQL)在SSO,但我还没有碰到适合我的解决方案来。

I have some excel files (xlsx) in an Azure VM and I want to push all of these to the SQL Database in Azure. 我在Azure VM中有一些Excel文件(xlsx),我想将所有这些文件推送到Azure中的SQL数据库。 This would be a repetitive task, (files come in from a source and have to pushed to DB) - required to be executed on a daily basis. 这将是一项重复性的任务(文件从源入库并且必须推送到DB)-需要每天执行。

I am planning to use this approach - 我正计划使用这种方法-

Current Solution - 当前解决方案 -

Custom code : A .NET app that uses OpenXML SDK/NPOI/EPPlus to read the files and manually push them to SQL Database (using .Net SQLBulkCopy). 自定义代码 :.NET应用程序,它使用OpenXML SDK / NPOI / EPPlus读取文件并将它们手动推送到SQL数据库(使用.Net SQLBulkCopy)。 App runs within the VM. 应用程序在VM中运行。

The problem with the above approach is that - it requires time to code and test with excel files of varying schema. 上述方法的问题是-它需要时间来编码和测试具有不同架构的excel文件。 I am looking to see if there other options that could avoid custom code. 我正在寻找是否有其他选项可以避免自定义代码。 Please note that there is no on-premise involvement here (So I presume no SSIS, no BCP(?) etc). 请注意,这里没有内部部署(因此我假设没有SSIS,没有BCP(?)等)。 This is not a one-time migration kind of activity. 这不是一次性迁移活动。

Other Options? 其他选择?

1) Access Database Engine? 1) 访问数据库引擎? : Can the "Access Database Engine" ( 2010 or 2013 ?) be used to get read the excel files rather than openXML or other tools? :可以使用“ Access Database Engine”( 20102013吗?)而不是openXML或其他工具来读取excel文件? It appears to be an alternate to the Jet.OLEDB in a 64 bit environment. 在64位环境中,它似乎是Jet.OLEDB的替代产品。 But I am unsure if this support excel 2007 formats as well and why would you choose this vs OpenXml SDK/NPOI/EPPlus if the job is just to read the excel file (no creation, manipulation) 但是我不确定是否也支持excel 2007格式,如果工作只是为了读取excel文件(不创建,不进行操作),为什么还要选择OpenXml SDK / NPOI / EPPlus?

2) BCP in Azure? 2) Azure中的BCP? : Can BCP used WITHIN azure? :BCP可以在天蓝色内使用吗? Not quite sure about this. 对此不太确定。 If so, would it make sense to convert XLSX to CSV and then use BCP to upload to SQL Database, thereby minimize the amount of code I have to write? 如果是这样, XLSX 转换为CSV,然后使用BCP上传到SQL数据库是否有意义,从而使我必须编写的代码量最少?

3) ExcelDataReader? 3) ExcelDataReader? : If custom code is the option, can the ExcelDataReader which is cross-platform (and I don't need cross platform capability) and supports both XLS and XLSX. :如果可以选择使用自定义代码,那么可以跨平台(并且我不需要跨平台功能)并且同时支持XLS和XLSX的ExcelDataReader可以。 ExcelDataReader is said to be faster - but unsure how faster is it when compared to reading files using OpenXML SDK or tools like NPOI/EPPlus 据说ExcelDataReader更快-但与使用OpenXML SDK或NPOI / EPPlus之类的工具读取文件相比,它不确定有多快

Appreciate thoughts from the community. 赞赏社区的想法。

from my experiences, option 2 would be the most pragmatic. 根据我的经验,选择2最为实用。 It is a matter of preference/familiarity whether you want to open the Excel documents with a library like ExcelDataReader or programmatically convert the file first to CSV and read as a delimited file. 是否要使用ExcelDataReader之类的库打开Excel文档,还是要先以编程方式将文件转换为CSV并作为分隔文件读取,都取决于您的偏好/熟悉程度。 Either way, BCP is relatively straightforward way to get data into SQL Database using custom code. 无论哪种方式,BCP都是使用自定义代码将数据获取到SQL数据库的相对简单的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM