title | description | titleSuffix | ms.date | ms.topic | dev_langs | helpviewer_keywords | author | ms.author | manager | ms.subservice | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Map schemas to worksheets inside Visual Studio |
Learn how you can map an XML schema to a Microsoft Office Excel worksheet while the worksheet is open in Visual Studio. |
02/02/2017 |
how-to |
|
|
John-Hart |
johnhart |
mijacobs |
office-development |
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 Office project creates the same objects whether you map the schema to the worksheet before or after you create your Excel solution.
[!INCLUDEappliesto_xlalldoc]
Note
You cannot use multipart XML schemas in Excel solutions.
-
Open the Excel workbook or template project inside Visual Studio.
-
Click in the worksheet to move the focus to the designer.
-
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.
-
In the XML group, click Source.
The XML Source window opens.
-
In the XML Source window, click XML Maps.
The XML Maps dialog box opens.
-
In the XML Maps dialog box, click Add.
-
Browse to your schema file, select it, and then click Open.
-
Click OK.
The schema is represented in the XML Source window. In your project, a typed xref:System.Data.DataSet is generated based on the schema, and a xref:System.Windows.Forms.BindingSource is created.
-
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, the Office project generates an xref:Microsoft.Office.Tools.Excel.XmlMappedRange control that is automatically bound to the xref:System.Windows.Forms.BindingSource.
If you drag a repeating schema element, the Office project generates a xref:Microsoft.Office.Tools.Excel.ListObject control that is not automatically bound to a data source. For more information, see XML schemas and data in document-level customizations.