Importing and Exporting Data
Enhanced Microsoft Query
An extremely powerful feature of Excel is the capability to retrieve data from external sources so that it can be analyzed and manipulated by the tools in Excel. Microsoft Query is a separate program that comes with Office and that works with Excel to make it easy to retrieve data from databases and copy the data into an Excel worksheet. You can then use any of the tools Excel provides such as PivotTable and charting, to work with the list of imported data.
You can access Microsoft Query directly from Excel to retrieve specific information from external sources, primarily databases. Some examples of the programs you can retrieve data from include Access, FoxPro, dBASE, and OLAP Cubes. You also can retrieve information from the Internet using HTML filters. The data can be filtered, sorted, formatted, or edited in Microsoft Query before it is inserted into your worksheet. The data can be retrieved by using either the Query Wizard, or directly from the Microsoft Query window. The Query Wizard helps you create quick and simple query designs to retrieve data; use it when you want to retrieve data from only one table in a database. If you want to retrieve data from multiple tables in a database, the Microsoft Query window enables you to work in more detail to customize and view your data retrieval.
To start Microsoft Query, choose Data, Get External Data, New Database Query. The Choose Data Source dialog box appears, as shown in Figure 3.50. You must identify the data source before you can create the query.
Microsoft Query is an optional feature in Excel, and may not be installed on your computer. If a warning message is displayed when you select New Database Query, then Microsoft Query is not installed. You need access to the Office 2000 CD or the location where the Office 2000 installation files are stored to install Microsoft Query.
You can create and distribute queries to other Excel users, so they don't have to repeat the steps of setting up the data source to run the query. A worksheet can be saved with a query as a template, without saving a copy of the retrieved data. When you open the report template, the external data is retrieved. You are prompted for a password if one is required. Queries can be created that prompt you for parameters each time they're run, so you can create more flexible queries and work with larger databases. Queries now run in the background, so you can continue to work on other things in Excel while data is being retrieved.
FIG. 3.50 Choose Data Source dialog box.
Enhanced Database, Web, and Text Queries
Excel 2000 includes client software that enables you to work with Online Analytical Processing (OLAP) databases. OLAP uses an alternative way to organize the data in very large databases to speed up data retrieval. Instead of arranging data into tables, the data is organized in levels, dimensions, and data values forming what are called OLAP data cubes. The data retrieved from an OLAP cube can be returned to Excel only in a PivotTable or PivotChart report. Choose Data, Get External Data, New Database Query to create the OLAP cube data source and start the query.
Web queries are designed to retrieve data from intranet or Internet Web sites that use the HTTP or FTP protocols. If you used this feature in earlier versions of Excel, you'll notice the process has been enhanced in Excel 2000. Several built-in financial Web queries are included in Excel or you can create your own Web queries. The Web queries provided with Excel connect to the Microsoft Investor Web site and import data into a worksheet.
To run one of the built-in queries, choose Data, Get External Data, Run Saved Query. The Run Query dialog box appears, as shown in Figure 3.51.
The process to import text or data from the Web has been enhanced in Excel 2000. The process for importing text includes an option to refresh the text; the formatting and formulas are retained when the data is refreshed. In addition, the procedures to import data from the Web have been simplified, making it easy for anyone to import data.
Text files are used when Excel cannot import a file type directly from another program, as most programs can save data to a text file. The three most common text file formats are Text (.txt), Formatted Text (.prn), and Comma-Separated Value (.csv).
In Excel 97 and earlier versions, you import text files either by opening the file (File, Open) or by creating a query in Microsoft Query. In Excel 2000, you can still open the file, but you no longer need to create a query to import a text file. Instead, use the new Import Text File option under the Data, Get External Data command.
There are a few differences between these two methods. When you use the File, Open method, the response by Excel depends on the file type you are attempting to open. If the file has a .txt or .prn extension, the Text Import Wizard begins (see Figure 3.52). If the file has a .csv extension, the file is immediately opened. When you use the Get External Data methods, Excel looks only for files with the .txt extension. However, you can force Excel to look for all files and select a .prn or .csv file. Regardless of the file type, the Text Import Wizard begins.
FIG. 3.51 Run Query dialog box.
FIG. 3.52 Step 1 of 3 in the Excel Text Import Wizard.