azure上传excel_使用MS Excel访问Azure中的关系SQL数据库

azure上传excel

介绍 (Introduction)

There are great Microsoft tools to access to SQL Server in Azure. However, as a Database Developers and Administrators we need to help the end user to access to the information using a familiar and intuitive interface.

有许多很棒的Microsoft工具可以访问Azure中SQL Server。 但是,作为数据库开发人员和管理员,我们需要使用熟悉且直观的界面来帮助最终用户访问信息。

Most of the end users have a good knowledge in MS Excel. That is why it is recommended to connect our SQL Azure database to Excel. That way, the end user will be able to easily create reports, charts and generate useful information.

大多数最终用户对MS Excel都有很好的了解。 因此,建议将SQL Azure数据库连接到Excel。 这样,最终用户将能够轻松创建报告,图表并生成有用的信息。

In this chapter, we will show how to connect to SQL Azure using Microsoft Excel.

在本章中,我们将展示如何使用Microsoft Excel连接到SQL Azure。

要求 (Requirements)

I am assuming that you already have a VM in Azure installed.

我假设您已经在Azure中安装了VM

  • An Azure subscription.

    Azure订阅。
  • my article about Azure VMs).参阅有关Azure VM的文章 )。
  • A local machine with Windows installed.

    安装Windows的本地计算机。
  • The Adventureworks or any other database with tables and views already created. In this article, we will use the Adventureworks.

    Adventureworks或任何其他具有表和视图的数据库已经创建。 在本文中,我们将使用Adventureworks。
  • this article for details. A SQL Server authentication enabled and a SQL login and password.本文 。 已启用SQL Server身份验证以及SQL登录名和密码。
  • For this article, I am using Excel 2013, but the 2010 will work.

    对于本文,我使用的是Excel 2013,但2010版可以使用。

入门 (Getting started)

  1. Open the Microsoft Excel 2013.

    打开Microsoft Excel 2013。

    Figure 1. The Microsoft Excel 图1. Microsoft Excel
  2. Go to the Data Menu and click the From Other Sources icon>From SQL Server.

    转到“ 数据”菜单,然后单击“ 来自其他来源”图标>“ 来自SQL Server”

    Figure 2. Connection to SQL Azure from Excel 图2.从Excel连接到SQL Azure
  3. In the Azure Portal in the Virtual Machines section, verify the virtual machine name used. Copy and paste the virtual machine name to be used.

    在“虚拟机”部分的“ Azure门户”中,验证使用的虚拟机名称。 复制并粘贴要使用的虚拟机名称。

    Figure 3. The Azure Portal, retrieving the Server name in Azure. 图3. Azure门户,检索Azure中的服务器名称。
  4. Paste the Azure virtual machine name with SQL Server and specify the SQL Server User name and the SQL Server Password.

    使用SQL Server粘贴Azure虚拟机名称,并指定SQL Server用户名和SQL Server密码。

    Figure 4. Login information to SQL Azure using the SQL Authentication 图4.使用SQL身份验证登录到SQL Azure的信息
  5. Select a Database. In this example, we will use the AdventureWorks2014 database. There are two options here. You can connect to a specific table/view or you can select multiple tables. In this example, we will connect to a specific table.

    选择一个数据库。 在此示例中,我们将使用AdventureWorks2014数据库。 这里有两个选择。 您可以连接到特定的表/视图,也可以选择多个表。 在此示例中,我们将连接到特定表。

    Figure 5. 图5. Selecting the SQL Azure Database 选择SQL Azure数据库
  6. Note that the icons for tables and views are different. You can also differenciate tables or views using the Type column.

    请注意,表和视图的图标不同。 您还可以使用“类型”列来区分表或视图。

    Figure 6. The tables and views 图6.表和视图
  7. For this example, we will use the Employee table of the AdventureWorks database, but any table with data can be used for this test.

    在此示例中,我们将使用AdventureWorks数据库的Employee表,但是任何带有数据的表均可用于此测试。

    Figure 7. 图7. The Employee table Employee表
  8. In Excel, an odc file is created to store the connection information. The ODC are Office Data Connection. You can specify where to store the file and specify a description, a friendly name and search keywords to search the files easily. Press the Browse button.

    在Excel中,将创建一个odc文件来存储连接信息。 ODC是Office数据连接。 您可以指定文件的存储位置,并指定描述,友好的名称和搜索关键字以轻松搜索文件。 按下浏览按钮。

    Figure 8. The odc file with the connection
    图8. 带有连接 odc 文件
  9. By default, the ODC files are stored in my documents>my data sources folder, but you can specify the path of your preference.

    默认情况下,ODC文件存储在“我的文档”>“我的数据源”文件夹中,但是您可以指定首选项的路径。

    Figure 9. The 图9. odc odc file path 文件路径
  10. If you open the file with a text editor, you will notice that it is a simple file with xml format and that it can be easily edited.

    如果使用文本编辑器打开文件,则会注意到它是xml格式的简单文件,并且可以轻松地对其进行编辑。

    Figure 10. The file content of the odc file
    图10. odc 文件 的文件内容
  11. You can import the data in a table, PivotTable Report, PivotChart and only create the connection. You can create the data in the existing worksheet or in a new one.

    您可以将数据导入表,数据透视表报表,数据透视图中,并且仅创建连接。 您可以在现有工作表或新工作表中创建数据。

    Figure 1 1 . How the SQL Server data will be displayed
    图1 1 SQL Server数据 将如何显示
  12. Once you press OK, You will notice that the data from the employees table is now in Excel.

    单击确定后,您将注意到,employees表中的数据现在位于Excel中。

    Figure 12. The SQL Azure data in Excel

    图12 Excel中SQL Azure数据

  13. If you try to edit the data you will edit it in Excel, but the changes are not reflected in the SQL Server Azure table. You mainly have access to the data to create special reports that can be easily done in MS Excel.

    如果尝试编辑数据,则将在Excel中对其进行编辑,但是更改不会反映在SQL Server Azure表中。 您主要可以访问数据来创建特殊的报告,这些报告可以在MS Excel中轻松完成。

    Figure 13 . Trying to edit the SQL data
    图13 尝试编辑SQL数据
  14. You can also use filters as you do with normal data in MS Excel.

    您也可以像使用MS Excel中的普通数据一样使用过滤器。

    Figure 14. Using Excel filters with the SQL data 图14.将Excel过滤器与SQL数据一起使用
  15. Now, let’s play with some formulas. Add the Age Column to the current table in Excel.

    现在,让我们玩一些公式。 将年龄列添加到Excel中的当前表。

    Figure 15 . Adding a column to the table
    图15 在表格中添加一列
  16. What we are going to do is to calculate the Age of a person using the birth date. We will do this using Excel. Add the following formula in the Age column:

    我们要做的是使用出生日期计算一个人的年龄。 我们将使用Excel进行此操作。 在“年龄”列中添加以下公式:

    =DATEDIF(G3,NOW(),”y”)

    = DATEDIF(G3,NOW(),“ y”)

    The formula shows the difference between the Birthdate column (G3) and the current date (NOW) in years (“y”).

    该公式显示“生日”列(G3)与当前日期(NOW)之间的年数(“ y”)之间的差异。

    Figure 1 6 . Adding a Formula in Excel
    图1 6 在Excel中添加公式
  17. As you can see, the Excel formulas can be easily used with the Azure data in SQL.

    如您所见,Excel公式可以轻松地与SQL中的Azure数据一起使用。

    Figure 17 . The results of the formula applied
    图17 应用公式的结果
  18. You can also create a nice dynamic reports using Power View. To access to Power View, select the data and go to the INSERT menu and select the Power View icon.

    您还可以使用Power View创建漂亮的动态报告。 要访问Power View,请选择数据并转到INSERT菜单,然后选择Power View图标。

    Figure 18. 图18. Enabling Power View 启用Power View
  19. If it is your first time running Power View, it will ask you to enable it and install Silverlight (if it is not installed).

    如果这是您第一次运行Power View,它将要求您启用它并安装Silverlight(如果尚未安装)。
  20. Once enabled and installed, you will have a new Sheet in Excel with dynamic data.

    启用并安装后,您将在Excel中创建一个包含动态数据的新图纸。

    Figure 19. 图19. The Power View information Power View信息
  21. You can create filters dynamically.

    您可以动态创建过滤器。

    Figure 20. 图20. Power View Fields Power View字段
  22. In this sample, we will create a simple report, in this sample; we will see the graphs of males and female employees based on the Business Entity ID.

    在此示例中,我们将在此示例中创建一个简单的报告; 我们将根据业务实体ID查看男性和女性雇员的图表。

    Figure 21. 图21. Selecting columns to graph 选择要绘制的列
  23. Select the Pie Chart option.

    选择饼图选项。

As you can see, the pie is created.

如您所见,创建了馅饼。

With Power View you can also create dynamic charts, working with geographical maps, etc. As you can see, working with SQL Server in an Azure VM using Excel is very easy.

使用Power View,您还可以创建动态图表,使用地理地图等。如您所见,使用Excel在Azure VM中使用SQL Server非常容易。

结论 (Conclusion )

As you can see, it is very easy to connect to SQL Server once the permissions are set. You can handle the SQL data to generate reports, graphs but not to edit the information. The connection is stored in odc files, which can be edited with any text editor. Excel 2013 with Power View enables you to create pretty nice dynamic reports.

如您所见,设置权限后,很容易连接到SQL Server。 您可以处理SQL数据以生成报告,图形,但不能编辑信息。 连接存储在odc文件中,可以使用任何文本编辑器进行编辑。 带有Power View的Excel 2013使您可以创建非常漂亮的动态报告。

翻译自: https://www.sqlshack.com/using-ms-excel-to-access-to-a-relational-sql-database-in-azure/

azure上传excel

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值