1. Trang chủ
  2. » Công Nghệ Thông Tin

how to do everything with ms office excel 2003 phần 9 pdf

44 418 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 44
Dung lượng 1,16 MB

Nội dung

334 How to Do Everything with Microsoft Office Excel 2003 HowTo-Tght (8) / How to Do Everything with Microsoft Office Excel 2003 / Hart-Davis / 3071-1 / Chapter 15 Another strong component of XML’s appeal is the validation it offers, which can provide a solution to the problems of formatting documents consistently and filling them in correctly. An XML document can validate its contents and formatting against the set of rules contained in the schema attached to it. For example, the schema attached to an invoice spreadsheet could ensure that cells mapped to specific elements contained data (rather than being empty) and that the data was of the required type. Likewise, the schema for a text document might require each table to be followed by a caption; validation could identify tables missing their captions. What You’re Likely to Do with XML Files Depending on the type of work you do, you’re likely to work with XML documents in one of two very different ways: ■ As a user Most people who use XML documents will fill in documents and create new documents by using existing schemas that developers in their company or organization created. To fill in existing XML documents and to create new XML documents based on existing schemas, you need only add a few skills to the core Excel and Word skills you probably already possess. ■ As a developer Someone needs to develop the XML documents and related schemas that the other users will work with. If you’re a developer of XML documents and schemas, you’ll need a much wider set of skills than if you just need to fill in the documents. Work with XML Files in Excel For opening, editing, and saving XML files, you use many of the same commands as for working with regular Excel worksheets and workbooks. First, you must understand the distinction between files in the XML Spreadsheet format and XML data files. XML Spreadsheet is a schema that enables Excel to save Excel workbooks (minus a few elements, such as AutoShapes, charts, and other objects, as well as VBA projects) in XML-encoded files. XML Spreadsheet files are Excel files encoded in XML rather than in the native Excel workbook format, so you open them, work with them, and save them in the same ways as regular Excel workbooks. By contrast, XML data files contain XML data, typically including references to external schemas. When you open an XML data file, you get to decide whether to import all of its data into an Excel worksheet, whether to open the file as a read-only list, or whether to perform a custom mapping of elements in the file’s attached schema to specify exactly which data you want to extract from the file. Open an XML Spreadsheet File in Excel You can open an XML spreadsheet in Excel by using standard Excel commands: ■ Choose File | Open to display the Open dialog box, navigate to and select the XML file, and click the Open button. (If necessary, choose the appropriate item in the Files of Type drop-down list to display the file type.) ■ Display the File menu and choose an XML file from the recently used area at the bottom of the menu. P:\010Comp\HowTo8\071-1\ch15.vp Friday, August 29, 2003 1:55:42 PM Color profile: Generic CMYK printer profile Composite Default screen 15 CHAPTER 15: Using Excel’s Web Capabilities 335 HowTo-Tght (8) / How to Do Everything with Microsoft Office Excel 2003 / Hart-Davis / 3071-1 / Chapter 15 ■ Right-click an XML file in a Windows Explorer window (or on the desktop) and choose Open With | Microsoft Excel from the shortcut menu. (The first time you do this, you may have to choose Open With | Choose Program and use the Open With dialog box to specify Excel. Thereafter, Excel will appear on the Open With shortcut menu.) Open an XML Data File in Excel You can open an existing XML data file in Excel by using the standard Excel commands mentioned in the previous section. What’s different is that, when you take any of these actions, Excel displays the Open XML dialog box: Choose the appropriate option button for your needs, and then click the OK button: ■ As an XML List Excel imports the data from the XML file into a new workbook containing one worksheet and displays the schema for the XML file in the XML Source task pane. ■ As a Read-Only Workbook Excel opens the XML file as a spreadsheet under its own name and doesn’t create a schema. The file is read-only, so you can’t save changes to it under its own name, but you can save changes to it under a different name. ■ Use the XML Source Task Pane Excel displays the schema for the XML file in the XML Source Task pane. From here, you can map the elements contained in the schema to cells or ranges in the worksheet. If you open the file as an XML list or using the XML Source task pane, and the XML file doesn’t contain a reference to a schema, Excel displays a message box informing you that it will create a schema based on the XML source data. Click the OK button to dismiss this message box (there’s no other choice but OK). You can suppress the display of this message box in the future if you want. Save Excel Files in XML Formats Excel can save your data either as an XML spreadsheet (retaining all data and most objects) or in XML data format (retaining just the data mapped to the elements in the XML schema attached to the workbook). To save a workbook in XML, follow these steps: 1. Click the Save button on the Standard toolbar or choose File | Save to display the Save As dialog box. (If the file has already been saved in a different format, choose File | Save As to display the Save As dialog box.) P:\010Comp\HowTo8\071-1\ch15.vp Friday, August 29, 2003 1:55:42 PM Color profile: Generic CMYK printer profile Composite Default screen 2. In the Save As Type drop-down list, select the XML Spreadsheet item or the XML Data item as appropriate. 3. Specify where to save the file as usual, and enter the file name. 4. Click the Save button to close the Save As dialog box. Excel saves the workbook in the specified format. Create XML Files in Excel The second and more difficult stage of using XML with Excel is creating your own XML files attached to an external schema and mapping the appropriate elements so as to be able to extract the relevant pieces of information from the files. First, you attach an XML schema to a workbook. This creates what’s called an XML map— a relationship between the schema and the workbook. You use this map to link elements in the schema to cells and ranges in worksheets in the workbook to define which element in the schema is represented by which cell. For example, you could map cells in a schema to specify which output from your manufacturing database you want to analyze in a worksheet containing custom calculations. A workbook can contain a single XML map or multiple XML maps. When a workbook contains multiple XML maps, each can refer to a different schema, or two or more maps can refer to the same schema. Once you’ve performed the mapping, you can export data from the mapped cells and ranges— for example, so you can use the data with another application. You can also import an XML data file into an existing XML mapping, so that the relevant parts of the data file snap into place. For example, you could import different months’ output from your manufacturing database so that you could analyze them. You can also use XML mapping to import XML-formatted data from a web source into a worksheet. Attach an XML Schema to a Workbook To attach an XML schema to a workbook, follow these steps: 1. Choose Data | XML | XML Source to display the XML Source task pane. 2. Click the Workbook Maps button to display the XML Maps dialog box: 336 How to Do Everything with Microsoft Office Excel 2003 HowTo-Tght (8) / How to Do Everything with Microsoft Office Excel 2003 / Hart-Davis / 3071-1 / Chapter 15 P:\010Comp\HowTo8\071-1\ch15.vp Friday, August 29, 2003 1:55:42 PM Color profile: Generic CMYK printer profile Composite Default screen 15 CHAPTER 15: Using Excel’s Web Capabilities 337 HowTo-Tght (8) / How to Do Everything with Microsoft Office Excel 2003 / Hart-Davis / 3071-1 / Chapter 15 3. Click the Add button to display the Select XML Source dialog box (which is a renamed Open dialog box). 4. Navigate to and select the XML schema you want to use. 5. Click the Open button. If the schema you specified contains more than one root element, Excel displays the Multiple Roots dialog box (shown here) so that you can choose which root element to use for the XML map. Select the root element and click the OK button. 6. Excel adds the XML map to the XML Maps dialog box: 7. If necessary, rename the map from its default name by clicking the Rename button (or clicking the Name entry for the map twice in slow succession), typing the new name, and pressing ENTER. P:\010Comp\HowTo8\071-1\ch15.vp Friday, August 29, 2003 1:55:43 PM Color profile: Generic CMYK printer profile Composite Default screen 338 How to Do Everything with Microsoft Office Excel 2003 HowTo-Tght (8) / How to Do Everything with Microsoft Office Excel 2003 / Hart-Davis / 3071-1 / Chapter 15 8. Click the OK button to close the XML Maps dialog box. The XML Source task pane displays the XML map you’ve added, showing the elements in the schema (or partial schema) as a hierarchical list: You can now map elements to cells in the workbook by using the XML Source task pane. Understand the Icons in the XML Source Task Pane The XML Source task pane uses different icons to represent the different elements in an XML schema. The following list explains what the icons mean. Icon Meaning Parent element Repeating parent element Required parent element P:\010Comp\HowTo8\071-1\ch15.vp Friday, August 29, 2003 1:55:43 PM Color profile: Generic CMYK printer profile Composite Default screen 15 CHAPTER 15: Using Excel’s Web Capabilities 339 HowTo-Tght (8) / How to Do Everything with Microsoft Office Excel 2003 / Hart-Davis / 3071-1 / Chapter 15 Icon Meaning Required repeating parent element Child element Repeating child element Required child element Required repeating child element Attribute Required attribute Simple content in a complex structure Map XML Elements to an Excel Worksheet To map XML elements from a schema to a worksheet, follow these steps: 1. If the XML Source task pane isn’t displayed, display it in one of the following ways: ■ Choose Data | XML | XML Source. ■ Choose View | Task Pane (or press CTRL-F1), and then choose XML Source from the task pane menu. 2. If you’ve added multiple maps to the workbook, select the appropriate map in the XML Maps in This Workbook drop-down list. 3. Select one or more elements in the schema: ■ Click a parent element to select it and all its child elements. ■ Click to select a single element. ■ CTRL-click to select multiple elements. P:\010Comp\HowTo8\071-1\ch15.vp Friday, August 29, 2003 1:55:43 PM Color profile: Generic CMYK printer profile Composite Default screen 340 How to Do Everything with Microsoft Office Excel 2003 HowTo-Tght (8) / How to Do Everything with Microsoft Office Excel 2003 / Hart-Davis / 3071-1 / Chapter 15 4. Drag the element or elements to the appropriate cell or range in the worksheet and drop it there. Excel adds the element and displays a blue border around the mapped cell to indicate that there’s a mapping. (This blue border doesn’t print.) ■ In the example spreadsheet shown here, the first_name and middle_initial elements have been added to the cells below their corresponding headings, and the employee_ number element is being dropped on cell A2: ■ You can also map an element to a cell by right-clicking it in the XML Maps in This Workbook list and choosing Map Element from the shortcut menu, using the Insert XML List dialog box to specify the cell or range, and clicking the OK button: ■ The XML Source task pane displays mapped elements in boldface and unmapped elements in regular font. ■ If Excel displays a Smart Tag when you map the field, you can choose the appropriate heading option from the Smart Tag’s menu. The choices are My Data Already Has a Heading, Place XML Heading to the Left, and Place XML Heading Above: P:\010Comp\HowTo8\071-1\ch15.vp Friday, August 29, 2003 1:55:43 PM Color profile: Generic CMYK printer profile Composite Default screen 15 CHAPTER 15: Using Excel’s Web Capabilities 341 HowTo-Tght (8) / How to Do Everything with Microsoft Office Excel 2003 / Hart-Davis / 3071-1 / Chapter 15 ■ When you map an element declared as having two or more values, Excel creates a drop-down list named after the element, as shown here. The drop-down list offers the Sort Ascending, Sort Descending, (All), (Top 10), and (Custom) choices that you’ll recognize from using AutoFilter (see “Perform Quick Filtering with AutoFilter,” in Chapter 9). To remove an element you’ve mapped, right-click it in the XML Source task pane and choose Remove Element from the shortcut menu. Configure Properties for an XML Map To configure properties for an XML map, you set the options in the XML Map Properties dialog box (Figure 15-8). You can display the XML Map Properties dialog box in either of two ways: ■ In the XML Source task pane, activate the appropriate map by selecting it in the XML Maps in This Workbook drop-down list. (If the workbook contains only one XML map, that map will be selected already.) Then choose Data | XML | XML Map Properties. FIGURE 15-8 Use the XML Map Properties dialog box to configure properties for an XML map. P:\010Comp\HowTo8\071-1\ch15.vp Friday, August 29, 2003 1:55:44 PM Color profile: Generic CMYK printer profile Composite Default screen 342 How to Do Everything with Microsoft Office Excel 2003 HowTo-Tght (8) / How to Do Everything with Microsoft Office Excel 2003 / Hart-Davis / 3071-1 / Chapter 15 ■ In the worksheet, right-click a cell to which one of the elements from the appropriate map is mapped and choose XML | XML Map Properties from the shortcut menu. You can set the following options in the XML Map Properties dialog box: ■ Name You can change the name assigned to the mapping. However, changing the name via the XML Maps dialog box is usually easier. ■ XML Schema Validation In this section, select or clear the Validate Data Against Schema for Import and Export check box to control whether Excel validates the data in this mapping against the schema when you import or export data. ■ Data Source In this section, the Save Data Source Definition in Workbook check box, which is selected by default, saves the XML binding in the workbook. Clear this check box to remove the XML binding from the workbook. This option is sometimes unavailable. ■ Date Formatting and Layout In this section, select or clear the three check boxes to specify whether or not to adjust column width; preserve column sorting, filtering, and layout; and preserve number formatting. ■ If the Number of Rows in the Data Range Changes upon Refresh/Import In this section, choose between the Insert Cells for New Data, Delete Unused Cells option button (the default setting) and the Overwrite Existing Cells with New Data, Clear Unused Cells option button. ■ When Refreshing/Importing Data In this section, choose between the Overwrite Existing Data with New Data option button (the default setting) and the Append New Data to Existing Data option button. In most cases, you’ll want to overwrite the existing data with the new data. Choose XML Options To configure how XML behaves in Excel, click the Options button near the bottom of the XML Source task pane and choose the appropriate menu item: ■ Preview Data in Task Pane Controls whether the XML Source task pane displays sample data next to each mapped element in the element list. By default, this check box is cleared. Previewing the data can help you identify problems in the mappings. ■ Hide Help Text in the Task Pane Controls whether Excel hides the help text that it normally displays below the element list in the XML Source task pane. ■ Automatically Merge Elements When Mapping Controls whether Excel automatically expands an XML list when you drop an element in the cell adjacent to the list. ■ My Data Has Headings Controls whether Excel uses your existing data as column headings when you map repeating elements to a worksheet. ■ Hide Border of Inactive Lists Controls whether Excel hides the borders of a list or cell when you select a cell outside the list. P:\010Comp\HowTo8\071-1\ch15.vp Friday, August 29, 2003 1:55:44 PM Color profile: Generic CMYK printer profile Composite Default screen 15 CHAPTER 15: Using Excel’s Web Capabilities 343 HowTo-Tght (8) / How to Do Everything with Microsoft Office Excel 2003 / Hart-Davis / 3071-1 / Chapter 15 Import an XML Data File into an Existing XML Mapping Once you’ve mapped the appropriate XML elements to cells or ranges in a workbook, you can import an XML data file into the mapping you’ve created. This creates what’s called an XML data binding between the XML data file and the XML map. Each XML map can have only a single XML data binding. That binding is bound to each mapping created from the XML map. Importing XML data in this way enables you to use Excel as a front end for manipulating data saved in XML format using the schema you’ve mapped to the workbook. This XML data can come from any XML-compliant source using the same schema. Using Excel like this helps companies avoid having to retrain users with XML applications, instead leveraging the users’ existing Excel skills and keeping the users within their comfort zone. To import an XML data file into an existing XML mapping, follow these steps: 1. Select a cell in the mapped range into which you want to import the data from the XML data file. 2. Click the Import button on the List and XML toolbar, or choose Data | XML | Import, to display the Import XML dialog box. 3. Navigate to and select the file you want to import, then click the Import button. 4. Excel checks the data and raises any issues: ■ If the XML data file doesn’t refer to a schema, Excel displays a dialog box to notify you that it will create a schema based on the source data. You can choose to suppress this warning in the future by selecting the In the Future, Do Not Show This Message option before dismissing the dialog box. ■ If Excel encounters a problem with the XML data file you’re trying to import, Excel displays the XML Import Error dialog box, which lists the errors encountered. You can select an error and click the Details button to display a dialog box giving more information on the error and where it occurred. This information may help you fix problems in the XML data file so that you can subsequently import it without errors. 5. Excel displays the Import Data dialog box to let you specify where to import the data: 6. Choose whether to import the list to the active worksheet (and if so, specify a location) or to a new worksheet. You can also set properties for the XML map by clicking the Properties button and working in the XML Map Properties dialog box. P:\010Comp\HowTo8\071-1\ch15.vp Friday, August 29, 2003 1:55:44 PM Color profile: Generic CMYK printer profile Composite Default screen [...]... P:\010Comp\HowTo8\071-1\ch16.vp Friday, August 29, 2003 1:56: 19 PM Use Excel with the Other Office Applications HowTo-Tght Color profile: Generic CMYK printer profile (8) / How to Do Everything with Microsoft Office Excel 2003 / Hart-Davis / 3071-1 / Chapter 16 Composite Default screen 346 How to Do Everything with Microsoft Office Excel 2003 How to ■ ■ ■ ■ ■ ■ Transfer data using the Clipboard and Office. .. table to edit it as an Excel object P:\010Comp\HowTo8\071-1\ch16.vp Friday, August 29, 2003 1:56:23 PM 16 HowTo-Tght Color profile: Generic CMYK printer profile (8) / How to Do Everything with Microsoft Office Excel 2003 / Hart-Davis / 3071-1 / Chapter 16 Composite Default screen 364 How to Do Everything with Microsoft Office Excel 2003 If you don’t like the results you get from pasting the “table” into... Friday, August 29, 2003 1:56:22 PM 16 HowTo-Tght Color profile: Generic CMYK printer profile (8) / How to Do Everything with Microsoft Office Excel 2003 / Hart-Davis / 3071-1 / Chapter 16 Composite Default screen 358 How to Do Everything with Microsoft Office Excel 2003 If you prefer to link the chart to its source in your Excel workbook, click the Paste Options Smart Tag and choose Link to Excel Chart... that represents your mailing database P:\010Comp\HowTo8\071-1\ch16.vp Friday, August 29, 2003 1:56:23 PM HowTo-Tght Color profile: Generic CMYK printer profile (8) / How to Do Everything with Microsoft Office Excel 2003 / Hart-Davis / 3071-1 / Chapter 16 Composite Default screen 362 How to Do Everything with Microsoft Office Excel 2003 8 Click the OK button to close the Select Table dialog box Word displays... application is updated P:\010Comp\HowTo8\071-1\ch16.vp Friday, August 29, 2003 1:56:21 PM 16 HowTo-Tght Color profile: Generic CMYK printer profile (8) / How to Do Everything with Microsoft Office Excel 2003 / Hart-Davis / 3071-1 / Chapter 16 Composite Default screen 354 How to Do Everything with Microsoft Office Excel 2003 FIGURE 16-3 Double-click an embedded object to edit it in place in the file that... FIGURE 16-4 P:\010Comp\HowTo8\071-1\ch16.vp Friday, August 29, 2003 1:56:21 PM Use the controls in the Edit Links dialog box to edit, update, and break links HowTo-Tght Color profile: Generic CMYK printer profile (8) / How to Do Everything with Microsoft Office Excel 2003 / Hart-Davis / 3071-1 / Chapter 16 Composite Default screen 356 How to Do Everything with Microsoft Office Excel 2003 Embedding and... together with the Change Icon button: To change the icon or caption, click the Change Icon button, use the options in the Change Icon dialog box (shown here) to specify the icon or the caption, and then click the OK button P:\010Comp\HowTo8\071-1\ch16.vp Friday, August 29, 2003 1:56:20 PM HowTo-Tght Color profile: Generic CMYK printer profile (8) / How to Do Everything with Microsoft Office Excel 2003. .. pane so that you can format the table manually P:\010Comp\HowTo8\071-1\ch16.vp Friday, August 29, 2003 1:56:22 PM 16 HowTo-Tght Color profile: Generic CMYK printer profile (8) / How to Do Everything with Microsoft Office Excel 2003 / Hart-Davis / 3071-1 / Chapter 16 Composite Default screen 360 How to Do Everything with Microsoft Office Excel 2003 The Paste Special dialog box offers a wide range of... location for the file to which you want to export the data 3 Click Export Excel exports the data 4 If there’s a problem with the schema, Excel displays a dialog box such as the one shown here Click the Details button to learn what the problem was P:\010Comp\HowTo8\071-1\ch15.vp Friday, August 29, 2003 1:55:44 PM HowTo-Tght (8) / How to Do Everything with Microsoft Office Excel 2003 / Hart-Davis / 3071-1...HowTo-Tght Color profile: Generic CMYK printer profile (8) / How to Do Everything with Microsoft Office Excel 2003 / Hart-Davis / 3071-1 / Chapter 15 Composite Default screen 344 How to Do Everything with Microsoft Office Excel 2003 7 Click the OK button in the Import Data dialog box to import the data If Excel discovers noncritical errors that allow it to import some or all of . screen 338 How to Do Everything with Microsoft Office Excel 2003 HowTo-Tght (8) / How to Do Everything with Microsoft Office Excel 2003 / Hart-Davis / 3071-1 / Chapter 15 8. Click the OK button to close. command 346 How to Do Everything with Microsoft Office Excel 2003 HowTo-Tght (8) / How to Do Everything with Microsoft Office Excel 2003 / Hart-Davis / 3071-1 / Chapter 16 P:10CompHowTo871-1ch16.vp Friday,. profile Composite Default screen 340 How to Do Everything with Microsoft Office Excel 2003 HowTo-Tght (8) / How to Do Everything with Microsoft Office Excel 2003 / Hart-Davis / 3071-1 / Chapter

Ngày đăng: 14/08/2014, 08:22

TỪ KHÓA LIÊN QUAN