Tutorial: Map inputs and outputs
See Tutorial: Get started in 5 minutes for an overview of this process.
If you have not done so already, we recommend applying the recommendations from How to: Prepare an Excel file for Spark to your candidate Excel file. Spark converts Excel calculations into integration-ready APIs. To convert your Excel calculations, the inputs and outputs of the file need to be identified.
Inputs are information you need to run the Excel calculation.
Outputs are the information you want to take from the Excel calculation.
For example, from the Tutorial: Get started in 5 minutes, to calculate the output for the volume of the cone, we need the inputs for radius and height.
Excel names
Spark uses Excel names to identify calculation inputs and outputs. If you are not familiar with Excel names, the Name Box, or the Name Manager please review the following articles from Microsoft.
The first character of a name must be a letter or an underscore character (_). Remaining characters in the name can be letters, numbers, periods, and underscore characters. In some languages, Excel may replace certain characters with underscores.
For Spark names, . is a reserved character used to Sub functions with subservices.
Sample file unmapped
In this tutorial you will learn to map inputs and outputs against a loan amortization schedule. The completed file is available in Sample file.
Map inputs and outputs
Syntax: Xinput_<parameter> and Xoutput_<parameter>
Load the sample file in Excel.
The file has cells that are cells shaded in orange as Input Cell Style. These are the input values that determine the repayment schedule of the loan.
Map the first input for the loan amount. Select cell
C3.For this tutorial, instead of using the Name Box, use the New Name dialog box. The New Name dialog box includes the ability to review the name scope and to add a comment. This can be opened from:
Select the Formulas tab and select Define Name OR,
Use the keyboard shortcut
Ctrl+Alt+F3.
In the New Name dialog enter
Xinput_loanas the Name. Spark recognizes an input if it is prefixed withXinput_.The scope by default is Workbook. Avoid using worksheet scoped names for Spark inputs and outputs.
Under the Comment, enter
Loan amount. Name comments are read in Spark and incorporated into the API documentation.Verify Refers to is
=Sheet1$C$3.Continue for the remaining inputs. The comments are optional and can be skipped.
AddressNameCommentRefers toC3Xinput_loanLoan amount
=Sheet1$C$3C4Xinput_rateAnnual Interest rate
=Sheet1$C$4C5Xinput_yearsLoan period in years
=Sheet1$C$5C6Xinput_payments_per_yearPayments per year
=Sheet1$C$6Note that each input already has a value in the file. These are used as the default values for these inputs. Spark will use these values during execution if these inputs are not provided and a warning will be raised.
Note that Data Validation has already been applied to each input in order to define the minimum and maximum allowable values. These input rules will be processed by Spark during execution and an error will be raised if an invalid input is provided. You can see the validation rules:
Select the input cell.
Select the Data tab and select Data Validation.
Use the keyboard shortcut
Alt + A + V + V.
This workbook already contains all of the formulas to calculate the loan amortization schedule. The file has cells that are shaded in grey as Output Cell Style. These are the output values that we want to take from the calculation.
Map the single value outputs. Outputs must be prefixed with
Xoutput_. The comments are optional and can be skipped.AddressNameCommentRefers toF3Xoutput_paymentPayment amount
=Sheet1$C$3F4Xoutput_periodsTotal number of payment periods
=Sheet1$C$4F5Xoutput_interestTotal interest paid
=Sheet1$C$5Tables in Spark need to be defined carefully.
The first row of a table is considered as the header row. Each field should be populated with a static value and be unique.
The remaining rows are considered as the data rows.
For input and output tables, make sure to define the length of the table to be sufficient for the table content.
If the table is not defined to be long enough, then the expected data will be truncated.
In this example, because the validation limits the maximum number of payments to
2 years × 12 months = 24 payments, the output range will have a height of24+1=25rows.Any excess blank rows at the end of the table are trimmed by Spark in the API response.
Never assign an
XinputorXoutputto a spill range such asD3#. The range always must be defined using cell addresses.
To map the amortization schedule, select the entire table range of
B9:G33and give it a name.AddressNameCommentRefers toB9:G33Xoutput_amortizationLoan amortization schedule
=Sheet1!$B$9:$G$33The mapping is complete and the file is ready to become a Spark service.
You can review all of the mappings in the Name Manager, either:
Select the Formulas tab and select Name Manager OR,
Use the keyboard shortcut
Ctrl+F3.
Read more about input and output mappings in Inputs and outputs (Xinput and Xoutput).
Sample file
Last updated
