Step 2. Complete Function iiiFN13
INT012 - Create Excel Document with Template and Formatting
In this step you will use an Excel file called Employs.xlsx as a template. Do not use an actual Excel template (i.e. file type .xltx). The file you use must have a .xls or .xlsx extension. The template looks like the following.
Note:
-
The list of employees will need to be placed in Row 5, Column 2.
-
The list of employees area has a left and right border, which will need to be defined before writing the Excel document.
1. Open and review your copy of the Employs.xlsx template.
2. To write the Excel document using the template you need to add the USING keyword to the ExcelService CREATE command. Your code should look like the following:
#jsmxcmd := 'CREATE USING(training/Employs.xlsx)'
USE BUILTIN(jsmx_command) WITH_ARGS(#jsmxhdle1 #jsmxcmd) TO_GET(#jsmsts #jsmmsg)
EXECUTE SUBROUTINE(CHECK_STS) With_Parms(#JSMXHDLE1)
3. You now need to write the working list of employees to Row 5, Column 2. Modify your WRITE command as required. Your code should look like the following:
* Write to Excel file
#jsmxcmd := 'WRITE R1C1(5,2)'
USE BUILTIN(jsmx_command) WITH_ARGS(#jsmxhdle1 #jsmxcmd) TO_GET(#jsmsts #jsmmsg #employs)
EXECUTE SUBROUTINE(CHECK_STS) With_Parms(#JSMXHDLE1)
4. Save your file. The training directory should be in your Integrator instance directory. Your code should look like the following:
* Save to Excel file
#jsmxcmd := 'SAVE FILE(training/jsmemp' + #datetimec + '.xlsx)'
USE BUILTIN(jsmx_command) WITH_ARGS(#jsmxhdle1 #jsmxcmd) TO_GET(#jsmsts #jsmmsg #employs)
EXECUTE SUBROUTINE(CHECK_STS) With_Parms(#JSMXHDLE1)
5. Compile function iiiFN13.