Use Formulas to Perform Association

Example

The Excel file book1.xlsx stores the employees meal records. Part of the data is as follows:

..

The task is to calculate the Meal charge and store the results in column D. The calculation rules are shown in the following table:

..

WriteSPLscritp:


A

1

=T("e:/work/book1.xlsx")

2

=A1.run('Meal charge'=case(Grade,"manager":case('Meal type',"breakfast":20,"lunch":30,"supper":40),"chief":case('Meal type',"breakfast":15,"lunch":20,"supper":25),"worker":case('Meal type',"breakfast":10,"lunch":15,"supper":20)))

3

=T("e:/work/book2.xlsx",A1)

A1Read the data of book1.xlsx

A2 Loop through each record and find the value of the Meal charge according to the values of Grade and Meal type

A3 Store the result in A1 to book2.xlsx