This article may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. To maintain the flow of the article, we've left these URLs in the text, but disabled the links.
|
Speed Your Documents to the Web with Microsoft Office 2000
Bruce Shankle |
The preview release of Microsoft Office 2000 reveals an innovative Web development platform. Developers can use the new Web features of the suite to create content like never before. |
Microsoft® Office 2000 is a comprehensive upgrade to one of the world's most popular software collections: Microsoft Access, Microsoft Excel, Outlook®, PowerPoint®, and Word. Although each application has plenty of spiffy new features, there are three fundamental goals for each: Web-enabled collaboration and information sharing, rich analysis tools for better decision-making, and ease of use and management. Microsoft Office 2000 promises to enable anyone with a Web browser on any platform to view Office-created content. You'll see how Office 2000 Developer (the edition of Office aimed at solution developers) will allow you to customize Office 2000 to ease the burden on your MIS staff. I'll also focus on how Office 2000 meets the first goal and some of the ancillary benefits you can use to build better Web apps. Office 2000 is currently in beta; the retail version is planned to hit the streets in the first half of 1999.
Round-trip Native HTML Support
|
Figure 1: Spreadsheet with Complex Data Types |
Skeptical? I didn't believe it
either until I ran Office 2000 through several tests. The Microsoft Excel spreadsheet shown in Figure 1 contains several cells of data, clip art, and sounds. I've intentionally used clip art and wave files represented as OLE objects because they don't have HTML equivalents. Saving this Microsoft
Excel spreadsheet as a Web page (see Figure 2) invokes the Office 2000 Save As dialog box (see
Figure 3). |
Figure 2: Saving a Spreadsheet as a Web Page |
Figure 3: Office 2000 Save As Dialog |
This Save As dialog box, common to all Office 2000 products, is the key to making Office Web publishing simple. It displays Web server locations as if they're just more folders. So saving a document as a page on a Web server is functionally equivalent to saving it as a binary file to your local drive. This makes it exceedingly simple for any Office user to publish Web content, thereby taking some of the load off Web managers. I chose to save the spreadsheet to a Web server on our network. When I click OK, my spreadsheet is magically transformed into a browser-friendly Web page on the server. That's all there is to it: plain, simple, and to the point. No wizards need apply. But does the HTML rendition of the document appear as it should? Surfing to the Microsoft Excel Web page I just saved reveals the answer (see Figure 4). Notice that the appearance of the Web page in Microsoft Internet Explorer is identical to the original spreadsheet. You'll be happy to know that the results are the same with all of the Office 2000 products. But what makes it even more exciting is the return trip. |
Figure 4: The Data is Preserved |
For the return trip you simply open or reopen a URL that points to an Office 2000 document that you (or another Office user) previously saved as a Web page. You can also open Web pages created outside Office. Starting the return trip is easy with the Office 2000 applications or with Internet Explorer. Just like FrontPage® does, Office 2000 enables the browser's Edit button. The Edit button puts this return trip one click away. If you've surfed to a Web page that you want to modify, simply click the Edit button (see Figure 5). Clicking the Edit button starts up the appropriate Office 2000 application and loads the document for editing. |
Figure 5: Editing a Web Page |
I am using the first beta
release of Office 2000 for this
review, but the results for round-tripping several documents through the Web server are surprisingly good using Internet
Explorer 4.0 and even a prerelease of Internet
Explorer 5.0. Having the Edit button in the browser toolbar is a simple yet key feature for Office users. It enables users to find documents with the browser, not the File dialog.
How Did They Do That?
Client-side Coolness with Office Web Components
|
Figure 8: Sample Spreadsheet |
Figure 9: Interactive Web Spreadsheet |
I've designed a sample spreadsheet that contains financial data (see Figure 8). The default sort is by Gross Sales. Previous versions of Microsoft Excel would indeed allow me to save this as a Web page, but I'd end up with a static HTML table. With Microsoft Excel 2000, I can click a checkbox during the Web save that enables client interactivity (see Figure 9). This tells Microsoft Excel 2000 I want users to have interactive access to the spreadsheet when they view it on the Web. When the resulting page is loaded into Internet Explorer, the SpreadSheet component renders the data kind of like Microsoft Excel lite (see Figure 10). It provides a clean subset of the Microsoft Excel program's capabilities to interact with the data. You can even experiment on the data by editing values. It is easy to change the sort order and perform several other useful spreadsheet tasks (see Figures 11 and 12). |
Figure 10: Less Filling, Tastes Great |
figure 11: Sorting by Net Sales |
figure 12: Results of Net Sales Sort |
Similar interactivity can be achieved with the PivotTable and PivotChart Web components. These components can be used to create highly interactive graphical Web pages. My next sample uses the PivotChart and PivotTable components on one page. When the page is initially loaded, the chart and table display total sales figures (see Figure 13). If you want to view only figures for May, you simply click the dropdown list in the pivot table (see Figure 14), check May, then click OK. The PivotTable and PivotChart dynamically update and show only the data you want (see Figure 15). For true enterprise usability, the data rendered in these components can come from dynamic queries to other data sources (like SQL Server). The information about how to reestablish the connections to the data sources is stored in the XML that is part of the Web page. |
figure 13: PivotChart and PivotTable |
figure 14: Using PivotTable |
figure 15: Dynamically Updating Data |
This functionality makes the Office 2000 Web components perfect for enabling easy interactive access to enterprise data on the Web. It couldn't be much easier. Although Office Web components allow you to deliver a high level of interactivity, they are client-centric, meaning they place certain requirements on users: they must use Internet Explorer 4.0 or 5.0, and they must have a valid installation of Office 2000. There may be times when you want to give similar functionality to users who don't have Internet Explorer or Office 2000. To do that, you can still use Office 2000; you just have to do it from the other end.
Server-side Solutions with Office 2000
|
|
The Excel.Application object is implemented as an out-of-process COM server. An instance of this object can only be created if the service processing the script (in this case, Internet Information Server) has permissions to run Excel.exe. For a variety of reasons, including security and performance, the default settings of Internet Information Server (IIS) prohibit ASP scripts from creating out-of-process components. You can change this setting by modifying a flag in the Web service metabase. This can be accomplished by executing the following ASP script in a Web that has Windows NT Challenge/Response user authentication turned on. You must be logged on as an administrator. |
|
For a complete discussion of these and other metabase settings, consult the documentation that accompanies IIS (or Personal Web Server). You should also read Don Box's House of COM column in the September 1998 issue of Microsoft Systems Journal that addresses this and other issues related to ASP and COM. Once you've enabled out-of-process components for your Web service (and you understand the security and server-resource implications), you're ready to take advantage of some Office 2000 capabilities to generate Web content. One way to do that is by using Microsoft Excel to create a chart on the Web. For this ASP script to function properly, you must add references to the Microsoft Excel object model and the Scripting object model to the global.asa file. Note that the full path and file name is required so ASP can locate the type libraries for these components. You may need to update these paths in global.asa depending on the location of the files on your system. global.asa |
|
By referencing these type libraries, you can use various Microsoft Excel constants by name, resulting in cleaner code. Here's a rundown (in English) of what the chart-generating ASP script does (the code is shown in Figure 16):
Once you have everything set up properly, point your browser at GenerateChartUsingExcel.asp to have Office 2000 generate a nifty chart (see Figure 17). If you're using Internet Explorer 4.0 or later, you'll notice a row of tabs across the bottom that give this Web page a spreadsheet feel. You can switch to Sheet1 to see the data that's rendered in the chart. |
figure 17: ASP-generated Microsoft Excel Chart in Office 2000 |
Several files result from the execution of this ASP script. The file to which I redirected the browser, charttest.htm, and all the other
files reside in the subdirectory charttest files. In this directory you'll find, among several other files, image001.gif. This is the snapshot in GIF format that was created to represent the chart in the browser (see Figure 18).
If you plan to get intimate with Office 2000 (through scripting like I've shown here or with Visual Basic®), you'll quickly discover that its object model is much like a first date. You know what you want, but at first you won't know how to get it. It's only fair to share a productivity trick with you.
A Productivity Trick
|
figure 19: Macro-recorded Chart |
Review the ASP script I used to generate my chart. You'll notice the code calls several methods of the Excel.Application object. If you think I spent a lot of time researching the Microsoft Excel object model to generate that code, you're wrong. I simply turned on the Microsoft Excel macro recorder and created a chart by hand (see Figure 19). Microsoft Excel tracked what I did and generated Visual Basic for Applications code that it stored as a macro. I referred to this code when I created the ASP script for chart generation (see Figure 20). |
Figure 20: Macro Code |
You can't simply copy and paste the Visual Basic for Applications macro into an ASP script, but the syntax is very similar. Using the macro recorder to map interactive work to the object model can save a lot of time. You can apply this technique when coding COM-aware languages to learn about the object model. It's not applicable in all cases, but it can be a great help in getting over the research curve. I wish more products implemented scripting object models and macro recorders. If you have an idea for a macro recorder I can use for shopping at my local hardware megastore, drop me a line!
Lighten Your Load with Office 2000 Developer
Ship It
|
From the December 1998 issue of Microsoft Interactive Developer.