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 ExcelAs usual, select File, Open to display the Open dialog box. After this, you have two choices:
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:
Excel's HTML Extension: The formula AttributeThe 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 WorksheetIf 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:
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. |