简体   繁体   English

将数据从 Excel 导出到 SQL Server 并生成报告

[英]Export data from Excel to SQL Server and report

I am working on a project where we would like to export data from a set of complex multi sheet Excel files in Sharepoint.我正在开发一个项目,我们希望从 Sharepoint 中的一组复杂的多表 Excel 文件中导出数据。 There are multiple tables as well as single kpi values to be extracted from each other Excel file.有多个表以及要从其他 Excel 文件中提取的单个 kpi 值。

The data will fit into the data model (of another database) we already have in SQL Server using an ID value present in the Excel file and SQL Server tables.使用 Excel 文件和 SQL Server 表中存在的 ID 值,数据将适合我们在 SQL Server 中已有的数据模型(另一个数据库的)。 All data is then consumed in a PowerBI report.然后在 PowerBI 报告中使用所有数据。

I have considered using powerapps, power automate or Azure Functions to achieve this.我已经考虑使用 powerapps、powerautomatic 或 Azure Functions 来实现这一点。 I have experience with Azure Functions but not the other two.我有 Azure Functions 的经验,但没有其他两个经验。 I am proficient in Python and SQL so I would prefer using those languages if possible.我精通 Python 和 SQL,所以如果可能的话,我更喜欢使用这些语言。

Other database types than SQL Server are also fine so long as the ID value is present it will be easy to join the data to the tables existing in the SQL Server database inside PowerBI.除了 SQL Server 之外的其他数据库类型也可以,只要 ID 值存在,就可以轻松地将数据连接到 PowerBI 内 SQL Server 数据库中现有的表。

My question is what would be the easiest, most user friendly way of achieving this?我的问题是实现这一目标的最简单、最用户友好的方法是什么? As much should be automated as possible but the issue with using Excel as an initial data source is that one small change in the Excel file, or data type may cause the automated process to fail.应该尽可能自动化,但使用 Excel 作为初始数据源的问题是 Excel 文件或数据类型中的一个小变化可能会导致自动化过程失败。 The inherent, breakable nature of excel files means that all it would take would be for one person to change something and the whole system is down, requiring additional work and money to fix it. excel 文件固有的、易损坏的性质意味着,一个人只需更改某些内容,整个系统就会停机,需要额外的工作和金钱来修复它。

Does anyone have experience if a similar project?有没有人有类似项目的经验?

I thought a power app would be easy to make and include in PowerBI.我认为强大的应用程序很容易制作并包含在 PowerBI 中。 The main KPIs could be manually entered but this would be an annoying and boring task for the user.主要 KPI 可以手动输入,但这对用户来说将是一项烦人且无聊的任务。

Using functions could pick up aa change or addition of a file in Sharepoint, extract the data using python and dump the data into SQL or any other database.使用函数可以在 Sharepoint 中获取文件的更改或添加,使用 python 提取数据并将数据转储到 SQL 或任何其他数据库中。 But this is open to being broken by changes in the Excel file.但这很容易被 Excel 文件中的更改破坏。

Cheers干杯

One trick I've done in such situations is to build INSERT SQL statements per row as a formula in the excel file itself using Excel string functions.我在这种情况下所做的一个技巧是使用 Excel 字符串函数将每行的 INSERT SQL 语句构建为 excel 文件本身中的公式。 You can hide the column from users.您可以对用户隐藏该列。 If the user adds columns, the formula will still work as Excel will handle rewriting it.如果用户添加列,公式仍将起作用,因为 Excel 将处理重写它。 It's easier to extract a single column from each tab you care about, as you can find it by the header name you choose.从您关心的每个选项卡中提取单个列更容易,因为您可以通过您选择的标题名称找到它。

This also works for quick-and-dirty one time manual data loads.这也适用于快速而肮脏的一次性手动数据加载。

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

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