26.1. Putting Worksheets on the Web
HTML (short for Hypertext Markup Language ) is the language of the Web. Web authors use it to craft pages with text, links, and graphics. In fact, HTML is so popular that it's no longer restricted to the Web. Even desktop programs often use it as an all-purpose way to display information. A typical Windows computer uses HTML to build help files, format email messages, display operating system updates, and even create fancy desktops.
In the early days of the Web, most programs had export-to-HTML features that weren't worth a second glance. They distorted formatting, mangled text, and generated HTML so ugly that professional Web developers fainted at the sight of it. Fortunately, the situation's improved. Though Excel's HTML exporting might never match the graphical flair of the most talented Web artists , it's still downright impressive. Best of all, you can have your data ready for Web surfers in a matter of minutes.
Note: It often makes sense to create HTML pages from your spreadsheets even if you don't intend to put them on the Internet. Maybe you want to email some information to another person who doesn't have Excel. Or maybe your company wants to put a collection of Web pages on a local intranet, so that everyone on the company network can use them. Either way, other people who don't have Excel can easily use a Web browser like Firefox or Internet Explorer to open HTML versions of your worksheets.
| UP TO SPEED |
Putting a Page on the Web
As you probably already suspect, if you want an HTML document to appear on the Web, it's not enough to just create the file. No one else will be able to find it unless you place that file on a Web site . Once your Web page turns up on a live Web site, surfers across the globe can go straight to it.
Personal computers rarely host Web sites. Instead, that job is usually handled by high- powered computers called Web servers . If you want to make your Web pages available over the Internet, you need to find a Web-hosting company that'll give you a little patch of space on one of their Web servers. You can then transfer your HTML pages to their computers so that other people can find them. (Ask around to find a reputable Web-hosting service, or search Google.)
26.1.1. Saving an HTML File
Using Excel, you can convert a single worksheet, a range of cells , or a whole workbook to an HTML file. Here's how:
Select the portion of the Excel file you want to convert to HTML .
If you want to export a single worksheet, move to that worksheet. Or, if you want to export a range of cells, select those cells. Step 3 tells you how to export the entire workbook.
Select Office button Save As .
This action opens the Save As dialog box.
From the "Save as type" list, choose Web Page .
When you do, the Save As dialog box changes a little bit, as shown in Figure 26-1.
| || |
Figure 26-1. When you're saving a spreadsheet as a Web page, the Save As dialog box gets a couple of new buttons . Use Change Title to set the Web page's title. You can also choose to save either the entire workbook or just the current selection.
Choose which portion of your workbook you want to export to HTML .
If you want to export every worksheet, select Entire Workbook. If you just want to export the current worksheet, then select Selection: Sheet. If you've already selected a range of cells, then you won't see the Selection: Sheet option. Instead, you'll see an option for the range of cells you chose, like "Selection: $A$2:$B$5".
Note: If you export the entire workbook, then Excel creates a Web page that includes worksheet tab buttons, which you can use to switch from one worksheet to another. Generally, it's simpler to just export a single worksheetthat makes more sense to Web surfers.
If you want to add a title, click the Change Title button. When the Set Page Title dialog box appears, type in a title for your Web page, and then click OK .
If you add a descriptive title, it appears in large bold font centered over the rest of your content. Titles don't have any restrictions, so feel free to use something clear and descriptive like "Blue Skies Budget Report" or "Bankruptcy Projections for 2008." This title also appears in the title bar of the Web browser window. (Without the title information, most Web browsers simply show the Web page file name in their title bar.)
Browse to the location where you want to save the Web page .
This location can be any of the places where you normally save files.
In the "File name" box, enter the name of the HTML file you want to create .
Depending on the content in your worksheet, Excel may create more than one file. If your worksheet contains embedded graphics or charts , or if you're printing the entire workbook, Excel creates additional files. Excel puts these files in a newly created folder that has the same name as your file, plus the text "_files."
If you save the Web page BudgetReport.htm, Excel creates a folder named BudgetReport_files to hold the extra files. You need to keep the HTML file and this folder together at all times, because the folder contains some information that the HTML file uses. (The box in Section 26.2 has more on these folders.)
You now have a choice to either save or publish your Web page .
If you want to perform a direct save of your file, effectively converting your current workbook into the HTML format, click the Save button. The original copy of your workbook remains in an .xlsx file, but Excel won't update it again unless you choose Office Menu Save As and explicitly select it.
If you want to publish your file, which creates a copy of your data in the HTML format, click Publish. This launches the "Publish as Web Page" dialog box, which gives you a last-minute chance to select the portion of the workbook you want to publish and to change the file name or Web page title. You've already set all the options you need, so just click Publish to save your HTML file. Your workbook remains in the .xlsx format, but Excel makes an HTML copy suitable for viewing in your browser.
Tip: When you use the "Publish as Web Page" dialog box, you can select "AutoRepublish every time this workbook is saved" to tell Excel to save the HTML copy of your workbook every time you save the .xlsx workbook file.
| NOSTALGIA CORNER |
Round Trips Meet a Dead End
Previous versions of Excel supported a remarkable (but seldom used) feature called round trips . Using the round trip feature, you could save your workbook as an HTML page, and then open that HTML page in Excel. Here's how it worked: Excel could recognize that this HTML page wasn't an ordinary piece of Web content. Amazingly, it would load all the workbook's data and formatting details without losing a byte of information, just as though the HTML page was a full-fledged Excel file. Even charts and macro code could make the transition from Excel to HTML and back to Excel again.
In Excel 2007, the round trip feature is gone. The difficulty of making it work with Excel's new features (combined with the fact that few people actually used and understood it) made it an easy cut. However, although you can't save round-trippable files with Excel 2007, you can still open HTML workbooks from earlier versions. Just use the Office button Open command, and then pick the HTML file. Once youve loaded an HTML workbook into Excel 2007, it's time to make the jump to the new Excel format and save it as a bona fide .xlsx workbook file.
The round trip feature isn't the only Web tool that was cut in Excel 2007. Another casualty was the ability to save interactive Web pagesWeb pages that allowed you to interact with Excel data in a limited number of ways. The interactive Web page offering bit the dust because it required an old-fashioned ActiveX control (a separate component that plugs into the browser), which raised security concerns, and didn't work with non-IE browsers or tightly locked-down corporate environments. The replacement feature is something called Excel Services, which allows a computer running Office SharePoint Server 2007 to host Excel documents and let people who don't have Excel view them. For more information about this feature, check out http://msdn2.microsoft.com/en-us/library/ms546696.aspx.
The exported copy of your worksheet is amazingly faithful. Excel preserves the formatting, layout, and content of your original worksheet. If your worksheet contains pictures or charts, Excel saves a separate graphic file for each object and displays it in the same Web page using the linking power of HTML. Figure 26-2 shows an exported worksheet that includes a chart.
| || |
Figure 26-2. The HTML version of a spreadsheet, as displayed in Internet Explorer (top), mimics its appearance in Excel (bottom) with surprising accuracy. You need to get used to a few minor changeslike the fact that the HTML version doesn't show any gridlines and can't correctly display fonts if they aren't installed on the computer that's viewing the Web page. The solution? Stick to fonts that come preinstalled on most computers nowadays: Arial, Courier New, Times New Roman, and Verdana (to name the most popular).
If you save an entire workbook, Excel's smart enough to create a Web page that includes separate frames for each worksheet, as shown in Figure 26-3. In this situation, you'll end up with extra filescheck out the box in Section 26.2 for the full story.
| || |
Figure 26-3. If you save an entire workbook, Excel adds a set of links that look like worksheet tabs at the bottom of the page. You can click these links to view the different worksheets. If a worksheet doesn't contain any data, Excel doesn't include a tab for it. Technically, Excel uses an HTML feature called frames to allow it to load separate worksheet pages in the same page.
| GEM IN THE ROUGH |
A Convenient Web Page Package
When you save your Excel data in an HTML page, Excel usually creates several filesone each for pictures and charts. Web browsers don't know anything about Excel charts, so Excel turns those into .gif files that any browser can display. Excel also uses additional files if you save an entire workbook, in which case it places each worksheet in a separate file.
In order to keep everything organized, Excel stores all these extra files in a linked folder. If you save your Excel file as the Web page BudgetReport.htm, Excel creates a folder called BudgetReport_files to hold extra files. Usually, you don't need to worry about which files are in this folder. Instead, you just load the main page (the one called BudgetReport. htm) in your Web browser.
You do, however, need to make sure the folder's always available, because the main page links to the files it contains. That means if you want to move your HTML page to another location or another computer, then you need to make sure that you copy the linked folder with it.
Keeping track of all these files can be a bit of a headache . What if you want to email your Excel Web page to another person? You'll need to not only email all the files, but also explain how to create the required directory to hold all these files.
Fortunately, you can use an easier solution. The trick is to save everything using a special Web archive format called .mht. When you save a .mht file, everything's combined into one compound file, including graphics. You can't easily edit .mht files, and they're supported only in Internet Explorer 4.0 or later (other browsers, like Firefox or Opera, need not apply). However, .mht files are a great way to package everything up into one file when you need to send it in an email.
To save a .mht file, select Office button Save As. In the "Save as type list, choose Single File Web Page. Choose any other options you want, and click Save or Publish to finish the job.