Displaying Web Pages in Excel


Excel supports the HTML format. Therefore, if a web page contains data that you need, the easiest way to get at it is to open the page right in Excel. This section shows you how to open web pages, explains Excel's HTML limitations, and outlines the HTML extensions that Excel supports.

Opening a Web Page in Excel

As usual, select File, Open to display the Open dialog box. After this, you have two choices:

  • If the page resides on your hard drive or LAN, use the Files of Type drop-down list to choose All Web Pages, select the file, and click Open.

  • If the page resides on the Internet or your corporate intranet, use the File Name text box to enter the web page's URL (for example, http://www.our-intranet.com/data.html), and then click Open.

Keep in mind, however, that Excel won't necessarily display the web page in the same way that a browser would. Although Excel's HTML support includes most formatting tags, there are quite a few tags it won't display. Here's a quick rundown of how Excel treats various categories of HTML tags:

  • Most character formatting tags are supported, including the tags for bold, italic, underlined, and monospaced text, as well as the <FONT> tag's various attributes (COLOR, SIZE, and FONT).

  • Heading tags are converted into the equivalent heading styles.

  • Links are preserved intact.

  • Definition lists are displayed as two-column lists, whereas bulleted and numbered lists are displayed in a single column.

  • <P> tags convert to blank rows.

  • Most table tags and attributes are supported.

Excel's HTML Extension: The formula Attribute

The formula attribute is an extension of both the <th> and <td> tags. Recall from the last chapter that you use <th> and <td> to define a single cell in a table. The formula attribute, as its name suggests, defines an Excel formula expression. When you use Excel to view a page that uses formula, Excel enters the formula into a cell and proceeds to calculate the result. Thus, with little effort and no programming whatsoever, you can create dynamic, formula-driven web pages.

Here's the syntax to use with the formula attribute:

formula="=expression"

Here, expression is a legal Excel expression, as shown in the following example:

<table>

<tr>

<th>Sales

<th>Expenses

<th>Profit

<tr>

<td>100

<td>85

<td formula="=A2-B2">Sales-Expenses

</table>

Figure 8.3 shows how Excel displays these tags. Notice how the formula defined by the formula attribute has been entered into cell C2. In contrast, Figure 8.4 shows the same page displayed in Internet Explorer. As you can see, the browser ignores the formula attribute completely and displays the text after the <td> tag.

Figure 8.3. Use the formula attribute to work with web page calculations while viewing the page in Excel.


Figure 8.4. Browsers ignore the formula attribute.


Adding a Live Stock Price Quote to a Worksheet

If you analyze financial data or maintain a stock portfolio, you can configure an Excel worksheet to display a live, refreshable stock price from MSN MoneyCentral. This is done using the Financial Symbol Smart Tag, which you activate as follows:

1.

Select Tools, AutoCorrect Options to display the Options dialog box.

2.

Select the Smart Tags tab.

3.

In the Recognizes list, activate the Financial Symbol check box.

4.

Click OK.

In your worksheet, enter the stock symbol you want to work with (such as MSFT for Microsoft). Point at the cell to display the Smart Tag, click the Smart Tag, and then click Insert Refreshable Stock Price.



Tricks of the Microsoft Office Gurus
Tricks of the Microsoft Office Gurus
ISBN: 0789733692
EAN: 2147483647
Year: 2003
Pages: 129

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net