Вы находитесь на странице: 1из 7

Page 1 of 7

Import data: Import external data into Excel


Overview
External data is data that is stored outside of Excel, in databases created in
Microsoft Office Access, Microsoft SQL Server™, or on a Web server, for
example. Whether that data is in a database stored on your computer or on a
remote server, it's a snap to import it into Excel.

Once you have the data in Excel, there are all sorts of ways you can analyze it.
You can use AutoFilter to see just the data you need to see, create PivotTable
reports to organize and summarize your data to reveal its meanings, or use
charts to create pictures out of the data.
Learn to import data that
is stored in a database And if the information in the external data changes, you can refresh the data
into Microsoft Office Excel in Excel to keep it up to date.
by using the Data
Connection Wizard

Goals
After completing this course you will be able to:

• Use the Data Connection Wizard to import external data that's stored locally on your hard drive or on a server.

• Reuse the Office Data Connection (.odc) files that connect to your external data sources.

About this course


This course includes:

• One self-paced lesson and one practice session for hands-on experience.

• A short test at the end of the lesson; the test is not scored.

• A Quick Reference Card you can take away from the course.

To learn about other ways to import external data, see the following courses:

• Import data: Import text files into Excel

• Import data: Filter external data before importing it into Excel

Use the Data Connection Wizard

Suppose you want to do some analysis of all the products sold by your
company. For example, how are certain products selling in comparison to
others, what are the costs of selling each product, and what is the sales
volume of each product compared to last year?

The data is stored in an Access database, but you want to use Excel to analyze
it. Use the Data Connection Wizard to get the data into Excel.

Use the Data Connection Wizard to import data into Excel.

Import external data to excel


Page 2 of 7

A word (or two) about external data

You can import many different kinds of databases into Excel.

Most likely the data you want to import will be stored in a corporate database. The data might be in a database on a local hard drive,
or it might be in a large server database such as Microsoft SQL Server or Oracle.

Know what you want to import


You can import many different kinds of data into Excel, including Microsoft SQL Server OLAP (On-Line Analytical Processing) Services
into PivotTable reports, Microsoft Access, dBASE, Microsoft FoxPro, Microsoft Excel, Oracle, Paradox, and SQL Server.

Know your connection type


Wherever the data comes from, each database management system uses a specific type of connection to enable data to be exported
into Excel. You'll select the connection type in a list that you'll see in the Data Connection Wizard that you use to import the data into
Excel.

For example, if your data is stored in a SQL Server database, you would pick that from the list. If you're not sure which to select, you
may need to ask your system administrator whether the data is stored in a SQL server database or in an Oracle database.

Office Data Connection files


Regardless of the kind of data you import, in the process you create an Office Data Connection (.odc) file. The .odc file stores the
connection information to the database, including the name and location of the database and the database driver, which is software
that connects to database programs.

Once you create an .odc file, you can use it again to connect to the same table in the database. For example, you might want to create
a new workbook later on to do different analyses with the same data.

Get started
On the Data menu, point to Import External Data, and then
click Import Data.

That opens the Select Data Source dialog box. See Figure 2.
The first time you open this dialog box you'll create a new data
source, so click the New Source button at the bottom right of
the dialog box.

That will open the Data Connection Wizard, which you will
Figure 1 On the Data menu, point to Import use to make the connection to your external data source. In the
first step of the wizard, you decide what kind of connection to
External Data, and then click Import Data. make.

In the next part of the course you'll see how to use the wizard
to make three different kinds of connections: an ODBC DSN
connection, a Microsoft SQL Server connection, and a Microsoft
SQL Server OLAP Services connection. Your system
administrator can tell you which of these connection types you
should use.

Import external data to excel


Page 3 of 7

Figure 2 Opening the Data Connection Wizard.

Click the the New Source button on the bottom of the Select Data Source dialog box...

... to open the Data Connection Wizard.

Create an ODBC connection


ODBC DSN is the most generic type of connection you can select in
the wizard.

ODBC stands for Open Database Connectivity, which is a program


file used to connect to a database. DSN stands for Data Source
Name.

In the first step of the Data Connection Wizard, you select ODBC
DSN as the connection type, and click Next (see Figure 1). You
can then select from several types of databases, including dBase
and Access.

Since the product data you want to import is stored in an Access


database, you'd select MS Access Database in the list and click
Next (see Figure 2).

You would then select the Access database you want to open, and
select the table you want to open. Excel will name the resulting file,
but you can pick another name. Then you import the data into
Figure 1 Decide what type of connection to make Excel by clicking Finish in the final step.

You'll see exactly how to do these steps in the practice at the end
of the lesson.
in the first step of the Data Connection Wizard.
Reuse an .odc file
Once the .odc file is created, whenever you reopen the Select
Data Source dialog box, this .odc file will be in the list of available
data sources that you can open. You can reuse the .odc file to
quickly connect to and import the same database table without
going through the Data Connection Wizard.

Note You can create as many .odc files as you need to the same
database, one for each table. Be sure that the names are
descriptive enough that you can tell them apart.

Import external data to excel


Page 4 of 7

Figure 2 Then decide what data source to connect to.

Create a Microsoft SQL Server connection

Microsoft SQL Server is selected as a connection type, and a user name and password are entered in the Data Connection
Wizard. An .odc file is created from a database and imported into Excel.

Now we'll see how to import the product data if it is stored on a Microsoft SQL Server instead of on a local hard drive.

SQL Server, called OLE DB, is a newer standard than ODBC DSN, and supports more data types, including images and sounds.

In the first step of the Data Connection Wizard, you select Microsoft SQL Server in the list, and then click Next.

In the next step, you enter the server name. If server log on credentials are necessary, you enter your user name and
password. Otherwise, choose Windows Authentication.

In the third step of the wizard, select the database that contains the data you want, and select the table you want to connect
to.

In the final step of the wizard, Excel names your .odc file (or you can pick another name). Then you click Finish.

The Select Data Source dialog box opens again, this time with your new .odc file in the list of files. You select the .odc file
and click Open. Before you import the data into Excel, you have the option to create a PivotTable report or to just import the
data as is into Excel. As a final step, if you entered your user name and password previously, you must enter them once again.
Then the data is imported into Excel.

Click the Play button on the left to see an animated example of creating a SQL connection.

Create an OLAP cube connection

Microsoft SQL Server OLAP Services is selected as a connection type, and a user name and password is entered in the
Data Connection Wizard. An .odc file is created from a database. The PivotTable and PivotChart Wizard opens, and
then the data is imported into Excel.

Now let's see how to create an OLAP cube connection.

Import external data to excel


Page 5 of 7

OLAP (On-Line Analytical Processing) is a way to organize large busines databases. OLAP databases are called cubes because
they combine several dimensions, such as time, geography, and product lines, with summarized data, such as sales or inventory
figures.

For this connection to work, you must have cube data to connect to, and the data must be on a SQL server database.

In the first step of the wizard, click Microsoft SQL Server OLAP Services. Then click Next.

You'll enter the server name, and if log on credentials are necessary, your user name and password. Otherwise, choose
Windows Authentication.

In the third step, you select the database you want, and then select the cube you want to connect to. Then click Next.

In the final step, the .odc file is named for you (or you can give it another name). Then you click Finish.

The Select Data Source dialog opens once again, this time with your new .odc file in the list. You select the .odc file and click
Open. Because OLAP data is imported only into PivotTable reports, the PivotTable and PivotChart Wizard opens. Click
Finish to create the report.

Click the Play button on the left to see an animated example of creating an OLAP connection.

Analyze and refresh the data

After the data is in Excel, you can filter it using AutoFilter, pivot
it by using PivotTable reports, or use charts. There are links in
the Quick Reference Card at the end of the course to courses
on how to do these tasks.

Whichever connection type you choose, after you import the


data, you can refresh the imported data if the external data
source is revised with new information. That way you can keep
the imported data up to date.

You can click the Refresh Data button on the External


Data toolbar or on the PivotTable toolbar to refresh the data.
Or you can refresh the data whenever you open the workbook,
or automatically refresh data at timed intervals. See the Quick
Reference Card for more information about refreshing data.
External Data toolbar.

PivotTable toolbar.

Prepare for the practice: Download an Access database

Import external data to excel


Page 6 of 7

Click the Download button to get the sample database for the practice steps.

Follow these instructions to download the Northwind Traders sample database so that you can do the practice session that's coming up.
The instructions may seem long, but they're not complicated, and it's best to do this all in one sitting.

1. To keep these instructions in front of you, print this page. On the File menu, click Print; in the Print dialog box, click
Preferences and set the orientation to Landscape. Click OK, then click Print.
2. When you have the printed instructions close at hand, create the following folder on your computer: C:\ExcelTraining. You'll
install the database here, in a minute.
3. Switch back to the training course.
4. Click this link: Northwind Traders Sample Database. This takes you to the download page titled "Access 2000 Tutorial:
Northwind Traders Sample Database."
5. On the right side of the page, click the Download button (see picture).
6. In the File Download dialog box, click Run.

You'll see a message asking if you want to run this software. You may have to click Run again.

Then you'll see a message asking if you want to install Northwind Traders Sample Database. Click Yes.

7. You'll see the terms of the License Agreement. Click Yes.


8. When prompted to type a location for the install or browse for it, click Browse. Go to C:\ExcelTraining. Select it, and click OK.
Click OK again, and click OK once more when a message says the installation was successful.
9. When the installation is done, if you have done these steps without interruption, you should have the "Access 2000 Tutorial:
Northwind Traders Sample Database" download page in front of you again.

Click the Back button in the browser twice to return to this training course page.

Now that you're back to the course, click Next for a few more instructions about the practice.

Practice

Now that you've downloaded the sample database, you'll import data
that is stored in it.

About the practice session


When you click Practice in Excel at the bottom of this page, a blank
worksheet will download to your computer and open in Excel, and a
separate window with practice instructions will appear alongside (see
picture).

Tips

• If the practice instructions aren't visible, or if they disappear


when you click in Excel, click the Excel Help taskbar button and
then click the Auto Tile button in the upper-left corner of the
instructions.

• If the practice instructions cover up Excel, click the Auto Tile


button in the upper-left corner of the instructions.
Before you begin
Make sure to close Excel if it is already running.

Start the practice


Click Practice in Excel now.

Practice instructions appear in a separate window alongside Excel.

Import external data to excel


Page 7 of 7

Test yourself

In the first step of the Data Connection Wizard, you: Select a connection type. Correct. The first step is to tell the wizard
what type of connection to make: ODBC DSN, Micosoft SQL Server, Oracle, or some other type of connection.

How do you save an .odc file so that you can use it again?. Complete the steps in the Data Connection Wizard.
Correct. If you do all the steps in the wizard, the .odc file is automtically created for you, and is stored in My Data Sources,
ready for you to use.

As you learned in the practice, you can only open the Data Connection Wizard by clicking the New Source
button. False. Correct. You can click either of two .odc files in the Select Data Source dialog box.

As you learned in the practice, when you open an .odc file that you created, the Data Connection Wizard does
not open. True. Correct. You don't need the wizard when you already have the .odc file.

Import external data to excel

Вам также может понравиться