![](/uploads/1/2/5/5/125519507/770754223.jpg)
![Combinar Combinar](http://3.bp.blogspot.com/-8ZTzr6daD34/ULzEmqlWN0I/AAAAAAAAAQk/AxFiDFqD_Ks/s1600/VPNUC1.png)
01 379035 ffirs.qxp4/18/0812:28 PMPage iiiMac OS® X Leopard™PARADUMmIES‰por Bob LeVitus 01 379035 f.
-->Conecte Excel a una base de datos única de Azure SQL Database e importe datos y cree tablas y gráficos basados en los valores de la base de datos.Connect Excel to a single database in Azure SQL Database and import data and create tables and charts based on values in the database.En este tutorial va a configurar la conexión entre Excel y una tabla de base de datos, guardar el archivo que almacena los datos y la información de conexión de Excel y, finalmente, crear un gráfico dinámico a partir de los valores de la base de datos.In this tutorial you will set up the connection between Excel and a database table, save the file that stores data and the connection information for Excel, and then create a pivot chart from the database values.
Antes de comenzar, necesitará una base de datos única.You'll need a single database before you get started.Si no tiene una, consulte Creación de una base de datos única y Create server-level IP firewall (Creación de un firewall de IP de nivel de servidor) para tener en funcionamiento en unos minutos una base de datos única con datos de ejemplo.If you don't have one, see Create a single database and Create server-level IP firewall to get a single database with sample data up and running in a few minutes.
En este artículo se importarán los datos de ejemplo en Excel de dicho artículo, pero puede seguir los pasos con sus propios datos.In this article, you'll import sample data into Excel from that article, but you can follow similar steps with your own data.
También necesitará una copia de Excel.You'll also need a copy of Excel.Este artículo usa Microsoft Excel 2016.This article uses Microsoft Excel 2016.
Conectar Excel a SQL Database y cargar datosConnect Excel to a SQL database and load data
- Para conectar Excel a Base de datos SQL, abra Excel y cree un libro nuevo o abra uno existente.To connect Excel to SQL database, open Excel and then create a new workbook or open an existing Excel workbook.
- En la barra de menús de la parte superior de la página, seleccione la pestaña Datos, Obtener datos, De Azure y luego seleccione De Azure SQL Database.In the menu bar at the top of the page, select the Data tab, select Get Data, select From Azure, and then select From Azure SQL Database.Se abre el Asistente para la conexión de datos.The Data Connection Wizard opens.
- En el cuadro de diálogo Conectar con el servidor de la base de datos, escriba el nombre del servidor de SQL Database al que quiere conectarse con el formato <nombreDeServidor> .database.windows.net.In the Connect to Database Server dialog box, type the SQL Database Server name you want to connect to in the form <servername>.database.windows.net.Por ejemplo, msftestserver.database.windows.net.For example, msftestserver.database.windows.net.También puede escribir el nombre de la base de datos.Optionally, enter in the name of your database.Seleccione Aceptar para abrir la ventana de credenciales.Select OK to open the credentials window.
- En el cuadro de diálogo Base de datos de SQL Server, seleccione Base de datos en el lado izquierdo y luego escriba el Nombre de usuario y la Contraseña del servidor de SQL Database al que se quiere conectar.In the SQL Server Database dialog box, select Database on the left side, and then enter in your User Name and Password for the SQL Database server you want to connect to.Seleccione Conectar para abrir el navegador.Select Connect to open the Navigator.SugerenciaDependiendo de su entorno de red, es posible que no pueda conectarse o que pierda la conexión si el servidor de SQL Database no permite el tráfico de la dirección IP del cliente.Depending on your network environment, you may not be able to connect or you may lose the connection if the SQL Database server doesn't allow traffic from your client IP address.Vaya al Portal de Azure, haga clic en Servidores SQL Server, haga clic en su servidor, haga clic en Firewall en Configuración y agregue la dirección IP de cliente.Go to the Azure portal, click SQL servers, click your server, click firewall under settings and add your client IP address.Consulte Configuración del firewall para obtener más detalles.See How to configure firewall settings for details.
- En el navegador, seleccione en la lista la base de datos con la que quiere trabajar, seleccione las tablas o vistas con las que quiere trabajar (se elige vGetAllCategories) y luego seleccione Cargar para mover los datos de la base de datos a la hoja de cálculo de Excel.In the Navigator, select the database you want to work with from the list, select the tables or views you want to work with (we chose vGetAllCategories), and then select Load to move the data from your database to your Excel spreadsheet.
Importación de los datos a Excel y creación de un gráfico dinámicoImport the data into Excel and create a pivot chart
Ahora que ha establecido la conexión, tiene varias opciones para cargar los datos.Now that you've established the connection, you have several different options with how to load the data.Por ejemplo, con los pasos siguientes se crea un gráfico dinámico basado en los datos de SQL Database.For example, the following steps create a pivot chart based on the data found in your SQL Database.
- Siga los pasos de la sección anterior, pero esta vez, en lugar de seleccionar Cargar, seleccione Cargar en en la lista desplegable Cargar.Follow the steps in the previous section, but this time, instead of selecting Load, select Load to from the Load drop-down.
- Luego seleccione cómo quiere ver estos datos en el libro.Next, select how you want to view this data in your workbook.Elegimos Gráfico dinámico.We chose PivotChart.También puede optar por crear una nueva hoja de cálculo o Agregar estos datos al Modelo de datos.You can also choose to create a New worksheet or to Add this data to a Data Model.Para más información sobre los modelos de datos, consulte Crear un modelo de datos en Excel.For more information on Data Models, see Create a data model in Excel.La hoja de cálculo ahora tiene una tabla y un gráfico dinámicos vacíos.The worksheet now has an empty pivot table and chart.
- En Campos de tabla dinámica, seleccione todas las casillas de los campos que desea ver.Under PivotTable Fields, select all the check-boxes for the fields you want to view.
Sugerencia
Si quiere conectar otros libros y hojas de cálculo de Excel a la base de datos, seleccione la pestaña Datos y luego Orígenes recientes para iniciar el cuadro de diálogo Orígenes recientes.If you want to connect other Excel workbooks and worksheets to the database, select the Data tab, and select Recent Sources to launch the Recent Sources dialog box.Desde allí, elija la conexión que ha creado en la lista y luego haga clic en Abrir.From there, choose the connection you created from the list, and then click Open.
Crear una conexión permanente con el archivo .odcCreate a permanent connection using .odc file
Para guardar los detalles de conexión de forma permanente, puede crear un archivo .odc y convertir esta conexión en una opción seleccionable del cuadro de diálogo Conexiones existentes.To save the connection details permanently, you can create an .odc file and make this connection a selectable option within the Existing Connections dialog box.
- En la barra de menús de la parte superior de la página, seleccione la pestaña Datos y luego Conexiones existentes para iniciar el cuadro de diálogo Conexiones existentes.In the menu bar at the top of the page, select the Data tab, and then select Existing Connections to launch the Existing Connections dialog box.
- Seleccione Buscar más para abrir el cuadro de diálogo Seleccionar origen de datos.Select Browse for more to open the Select Data Source dialog box.
- Seleccione el archivo +NewSqlServerConnection.odc y luego Abrir para abrir el Asistente para la conexión de datos.Select the +NewSqlServerConnection.odc file and then select Open to open the Data Connection Wizard.
- En el Asistente para la conexión de datos, escriba el nombre del servidor y las credenciales de SQL Database.In the Data Connection Wizard, type in your server name and your SQL Database credentials.Seleccione Next (Siguiente).Select Next.
- Seleccione la base de datos que contiene los datos en la lista desplegable.Select the database that contains your data from the drop-down.
- Seleccione la tabla o vista que le interesa.Select the table or view you're interested in.Se elige vGetAllCategories en este caso.We chose vGetAllCategories.
- Seleccione Next (Siguiente).Select Next.
- Seleccione la ubicación del archivo, el Nombre de archivo y el Nombre descriptivo en la siguiente pantalla del Asistente para la conexión de datos.Select the location of your file, the File Name, and the Friendly Name in the next screen of the Data Connection Wizard.También puede optar por guardar la contraseña en el archivo, aunque esto puede exponer los datos a accesos no deseados.You can also choose to save the password in the file, though this can potentially expose your data to unwanted access.Seleccione Finalizar cuando esté listo.Select Finish when ready.
- Seleccione cómo quiere importar los datos.Select how you want to import your data.En este caso se ha optado por una tabla dinámica.We chose to do a PivotTable.También puede modificar las propiedades de la conexión si selecciona Propiedades.You can also modify the properties of the connection by select Properties.Seleccione Aceptar cuando esté listo.Select OK when ready.Si no ha optado por guardar la contraseña con el archivo, se le pide que especifique las credenciales.If you did not choose to save the password with the file, then you will be prompted to enter your credentials.
- Compruebe que la nueva conexión se ha guardado al expandir la pestaña Datos y seleccionar Conexiones existentes.Verify that your new connection has been saved by expanding the Data tab, and selecting Existing Connections.
Pasos siguientesNext steps
- Consulte Conexión a la SQL Database con SQL Server Management Studio y realización de una consulta de T-SQL de ejemplo para obtener más información sobre consultas y análisis avanzados.Learn how to Connect to SQL Database with SQL Server Management Studio for advanced querying and analysis.
- Más información sobre las ventajas de los grupos elásticos.Learn about the benefits of elastic pools.
- Más información en Crear una aplicación ASP.NET MVC con la autenticación y SQL Database e implementar al Servicio de aplicaciones de Azure.Learn how to create a web application that connects to SQL Database on the back-end.
![](/uploads/1/2/5/5/125519507/770754223.jpg)