Share via


How to: Map Schemas to Worksheets Inside Visual Studio

Applies to

The information in this topic applies only to the specified Visual Studio Tools for Office projects and versions of Microsoft Office.

Project type

  • Document-level projects

Microsoft Office version

  • Excel 2007

  • Excel 2003

For more information, see Features Available by Application and Project Type.

You can map an XML schema to a worksheet while the worksheet is open in Visual Studio. You use the same Microsoft Office Excel tools that you use when the workbook is open outside of Visual Studio. The Visual Studio Tools for Office project creates the same objects whether you map the schema to the worksheet before or after you create your Excel solution.

The procedures are different for Excel 2007 and Excel 2003.

Note

You cannot use multipart XML schemas in Excel solutions.

To map an XML schema to an Excel 2007 worksheet in Visual Studio

  1. Open the Excel workbook or template project inside Visual Studio.

  2. Click in the worksheet to move the focus to the designer.

  3. On the Ribbon, click the Developer tab.

    Note

    If the Developer tab is not visible, you must first show it. For more information, see How to: Show the Developer Tab on the Ribbon.

  4. In the XML group, click Source.

    The XML Source window opens.

  5. In the XML Source window, click XML Maps.

    The XML Maps dialog box opens.

  6. In the XML Maps dialog box, click Add.

  7. Browse to your schema file, select it, and then click Open.

  8. Click OK.

    The schema is represented in the XML Source window. In your project, a typed DataSet is generated based on the schema, and a BindingSource is created.

  9. Drag elements from the XML Source window to the places in your worksheet where you want the corresponding controls to be created.

    If you drag a non-repeating schema element, Visual Studio Tools for Office generates an XmlMappedRange control that is automatically bound to the BindingSource.

    If you drag a repeating schema element, Visual Studio Tools for Office generates a ListObject control that is not automatically bound to a data source. For more information, see XML Schemas and Data (Visual Studio Tools for Office).

To map an XML schema to an Excel 2003 worksheet in Visual Studio

  1. Open the Excel workbook or template project inside Visual Studio.

  2. Click in the worksheet to move the focus to the designer.

  3. On the Data menu, point to Microsoft Office Excel Data, point to XML, and then click XML Source.

    The XML Source window opens.

  4. In the XML Source window, click XML Maps.

    The XML Maps dialog box opens.

  5. In the XML Maps dialog box, click Add.

  6. Browse to your schema file, select it, and then click Open.

  7. Click OK.

    The schema is represented in the XML Source window. In your project, a typed DataSet is generated based on the schema, and a BindingSource is created.

  8. Drag elements from the XML Source window to the places in your worksheet where you want the corresponding controls to be created.

    If you drag a non-repeating schema element, Visual Studio Tools for Office generates an XmlMappedRange control that is automatically bound to the BindingSource.

    If you drag a repeating schema element, Visual Studio Tools for Office generates a ListObject control that is not automatically bound to a data source. For more information, see XML Schemas and Data (Visual Studio Tools for Office).

See Also

Tasks

How to: Map Schemas to Word Documents Inside Visual Studio

Concepts

XML Schemas and Data (Visual Studio Tools for Office)