This is an example showing how to map properties in the generated code for your Excel
application.
Prerequisites
You have generated code for an Excel add-in application using the GWM Excel add-in
wizard.
Context
The example contains code snippets, and shows how to customize the generated code in the
class, ExcelDataManager.cs, by mapping and binding a property to
a column in the Excel; and then performing an update using the class,
SubmitChangesViewModel.cs.
Procedure
- From the Solution Explorer, open the class,
- Go the method, CreateExcelBindingTable, and add an
additional column in the Excel data table.
Example For example, add the following line:
this.ExcelDataTable.Columns.Add(GetDataColumn("BankName", "System.String"));
Notice that you are expected to provide a property name, and the equivalent
C# data type formatting to the
EdmType of the property. You can find all the
properties in the service proxy class, .
- Go to the method, BindExcelTableWithRecords, and add the relevant
service response data binding to the new column you added in Excel data
table.
Example For example, add following line:
dataRow["BankName"] = entity.BankName;
- You may skip this step if the Create, Update, and
Delete functionality are not supported in the OData
service. If these functionlaty are supported in the service, then perform the
following to change the methods that handle and modify the
ETag functionality:
- Go to the method, FillEntityWithData, and then to the newly added
column in the Excel data table.
Example For example:
if (!dataRow.IsNull("BankName")){ entity.BankName = dataRow["BankName"].ToString(); }
- Open the class, .
- Go to the method, GetSAPData.
Add the following code
snippet:
sapDataRow["BankName"] = recordFromBE.BankName;
- Go to the method, UpdateRowValues.
Add the following code snippet:
rowToUpdate["BankName"] = recordFromBE.BankName;
- Re-build and test your project for the Excel add-in application.