Chapter 28. Excel and the Internet

IN THIS CHAPTER

Saving Excel files in HTML format

Creating hyperlinks

Importing data from a Web page

Most people who use a computer are connected to the Internet. The Web has become an important way to share and gather information from myriad sources. To help you with these tasks, Excel has the capability to create files that you can use on the Internet and also to gather and process data from the Web. This chapter covers topics related to Excel and the Internet.

NOTE

Four of the Office 2010 applications are available in online versions: Excel, Word, PowerPoint, and OneNote. You can run these applications from within your Web browser. The online version of Excel is not the topic of this chapter, and is not covered in this book. Rather, the chapter deals with Internet-related features for the standard version of Excel.

28.1. Understanding How Excel Uses HTML

HTML (HyperText Markup Language) is the language of the World Wide Web. When you browse the Web, most documents that your browser retrieves and displays are in HTML format. An HTML file consists of text information plus special tags that describe how the text is to be formatted. The browser interprets the tags, applies the formatting, and displays the information.

28.2. Understanding the Different Web Formats

You can save an Excel workbook so that it's viewable in a Web browser. When you save an Excel workbook for viewing on the Web, you have two options:

  • An HTML file: Produces a static Web page, plus a folder that contains support files. You can create the HTML file from the entire workbook or from a specific sheet.

  • A single file Web page: Produces a MIME HTML file (*.mht; *.mhtml). Not all browsers can open these files.

These options are described in the following sections. Both examples use a simple two-sheet workbook file. Each sheet has a table and a chart. Figure 28.1 shows one of these worksheets.

Keep in mind that these files are intended to be only displayed by a Web browser. They are not interactive files. In other words, the user cannot make any changes while viewing the file.

Figure 28.1. This workbook will be saved in Excel Web formats.

NOTE

This workbook, named webpage.xlsx, is available on the companion CD-ROM.

28.2.1. Creating an HTML file

To save a workbook as an HTML file:

  1. (Optional but recommended) Save the workbook as a normal Excel file.

  2. Choose File Save As to display the Save As dialog box.

  3. Select Web Page (*.htm; *.html) from the Save as Type drop-down list.

  4. Specify what to save (either Entire Workbook or the active sheet).

  5. Specify a filename and then choose a location for the file.

  6. Click Save to create the HTML file. Excel may display a message warning you that some features in the workbook are not compatible with the Web page format. You can just ignore this message.

Although Excel can open the HTML files that it creates, essential information is lost. For example, formulas are lost, and charts appear as static graphic images. Therefore, if you might need to make changes later on, make sure you keep a copy of your work in a standard Excel file format.


Figure 28.2 shows how Sheet1 of the example file looks in a browser: Firefox, in this case. Notice that the workbook's sheet tabs appear along the bottom, and you can switch sheets just like you do in Excel.

In addition to the webpage1.htm file, Excel also created a folder named webpage1_files. This folder contains additional files that must be kept with the main HTML file. Therefore, if you post such a file on a Web server, don't forget to also post the accompanying directory.

28.2.2. Creating a single file Web page

In the previous section, I discuss how creating an HTML file with Excel also creates a folder of additional files. The procedure for creating a Web page that uses a single file is exactly the same, except for Step 3. In Step 3, select Single File Web Page (*.mht; *.mhtml) from the Save as Type drop-down list.

Figure 28.3 shows the example file displayed in Internet Explorer.

As I mention previously, not all browsers can open single-file MHTM files. Two that can are Microsoft Internet Explorer (IE) and Opera. Other browsers (such as Firefox and Google Chrome) may require an add-on to display these files.


Figure 28.2. Viewing the HTML file in a browser.

Web Options

If you save your work in HTML format, you should be aware of some additional options. In the Save As dialog box, click Tools and then choose Web Options to display the Web Options dialog box. From this dialog box you can control some aspects of the HTML file, such as target browser version (Internet Explorer only), target monitor resolution, and fonts. Most of the time, the default settings work just fine. However, if you plan to save Excel files in HTML format, familiarizing yourself with the options available is worthwhile. These options are described in the Help system.


Figure 28.3. Viewing the single file Web page in Internet Explorer.

28.3. Opening an HTML File

Excel can open most HTML files, which can be stored on your local drive or on a Web server. Choose File Open and locate the HTML file. If the file is on a Web server, you'll need to copy the URL and paste it into the File Name field in the Open dialog box.

How the HTML code renders in Excel varies considerably. Sometimes, the HTML file may look exactly as it does in a browser. Other times, it may bear little resemblance, especially if the HTML file uses Cascading Style Sheets (CSS) for layout.

After opening an HTML file, you can work with the information using the normal Excel tools.

Another way to open an HTML file from a Web server is to use a Web query, which is discussed later in this chapter (see "Using Web Queries").

28.5. Using Web Queries

Excel enables you to pull in data contained in an HTML file by performing a Web query. The data is transferred to a worksheet, where you can manipulate it any way you like. Web queries are especially useful for data that is frequently updated, such as stock market quotes.

The term "Web Query" is a bit misleading. You can perform a Web Query on a local HTML file, a file stored on a network server, or a file stored on a Web server on the Internet. To retrieve information from a Web server, you must be connected to the Internet. After the information is retrieved, an Internet connection is not required to work with the information (unless you need to refresh the query).

NOTE

Performing a Web query doesn't actually open the HTML file in Excel. Rather, it copies the information from the HTML file.

The best part about a Web query is that Excel remembers where the data came from. Therefore, after you create a Web query, you can refresh the query to pull in the most recent data.

To create a Web query

  1. Choose Data Get External Data From Web. Excel displays the New Web Query dialog box, shown in Figure 28.6. This dialog box is actually a resizable dialog box that functions as a Web browser.

  2. Click links to navigate, or just type the URL of the HTML file in the Address field. The HTML file can be on the Internet, on a corporate intranet, or on a local or network drive. Each table in the document is indicated by an arrow in a yellow box.

  3. Click an arrow to select the table or tables you want to import.

  4. You can also control how the imported data is formatted. In the New Web Query dialog box, click Options (upper right) to display the Web Query Options dialog box. Select the desired formatting and then click OK to return to the New Web Query dialog box.

  5. When you're ready to retrieve the information, click Import.

  6. In the Import Data dialog box that opens, choose where you want to place the data. The information on the Web page is retrieved and placed on your worksheet.

After you create your Web query, you have some options. Right-click any cell in the data range and choose Data Range Properties from the shortcut menu. Excel displays the External Data Range Properties dialog box, shown in Figure 28.7. These settings control when the data is refreshed, how it is formatted, and what happens if the amount of data changes when the query is refreshed.

To force a refresh at any time, right-click any cell in the data range and choose Refresh. The data in your worksheet is replaced by the latest of content of the Web page.

Figure 28.6. Use the New Web Query dialog box to specify the source of the data.

Figure 28.7. Use the External Data Range Properties dialog box to specify how Excel handles the imported data.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset