Allow loops for creating multiple worksheets
This commit is contained in:
63
swagger.yaml
63
swagger.yaml
@@ -56,26 +56,31 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
type: object
|
type: object
|
||||||
required:
|
required:
|
||||||
- worksheet-name
|
|
||||||
- out-filename
|
- out-filename
|
||||||
properties:
|
properties:
|
||||||
files:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: '#/definitions/direktivFile'
|
|
||||||
description: File to create before running commands.
|
|
||||||
default: []
|
|
||||||
infile:
|
|
||||||
type: string
|
|
||||||
description: Name of the json input file to utilise
|
|
||||||
worksheet-name:
|
|
||||||
type: string
|
|
||||||
description: Label for the worksheet created in the spreadsheet
|
|
||||||
default: "Sheet1"
|
|
||||||
out-filename:
|
out-filename:
|
||||||
type: string
|
type: string
|
||||||
description: the filename of the output spreadsheet
|
description: the filename of the output spreadsheet
|
||||||
default: "output.xlsx"
|
default: "output.xlsx"
|
||||||
|
sheets:
|
||||||
|
type: array
|
||||||
|
description: Array of worksheets to create in spreadsheet
|
||||||
|
items:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
worksheet-name:
|
||||||
|
type: string
|
||||||
|
description: Label for the worksheet created in the spreadsheet
|
||||||
|
default: "Sheet1"
|
||||||
|
infile:
|
||||||
|
type: string
|
||||||
|
description: Name of the json input file to utilise
|
||||||
|
input-file:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/direktivFile'
|
||||||
|
description: File to create before running commands
|
||||||
|
default: []
|
||||||
# direktiv code generation is configured here
|
# direktiv code generation is configured here
|
||||||
x-direktiv-function: |-
|
x-direktiv-function: |-
|
||||||
functions:
|
functions:
|
||||||
@@ -91,12 +96,14 @@ paths:
|
|||||||
action:
|
action:
|
||||||
function: export-xlsx
|
function: export-xlsx
|
||||||
input:
|
input:
|
||||||
files:
|
|
||||||
- name: input.json
|
|
||||||
data: |
|
|
||||||
jq(.input)
|
|
||||||
worksheet-name: "TestSpreadsheet"
|
|
||||||
out-filename: example.xlsx
|
out-filename: example.xlsx
|
||||||
|
sheets:
|
||||||
|
- sheet:
|
||||||
|
worksheet-name: "TestSpreadsheet"
|
||||||
|
input-file:
|
||||||
|
- name: input.json
|
||||||
|
data: |
|
||||||
|
jq(.input)
|
||||||
- title: Use jq to add a parent key 'input' containing array of objects
|
- title: Use jq to add a parent key 'input' containing array of objects
|
||||||
content: |-
|
content: |-
|
||||||
- id: export-xlsx
|
- id: export-xlsx
|
||||||
@@ -104,19 +111,23 @@ paths:
|
|||||||
action:
|
action:
|
||||||
function: export-xlsx
|
function: export-xlsx
|
||||||
input:
|
input:
|
||||||
files:
|
|
||||||
- name: input.json
|
|
||||||
data: |
|
|
||||||
jq(.array | {input: . } | tostring )
|
|
||||||
worksheet-name: "TestSpreadsheet"
|
|
||||||
out-filename: example.xlsx
|
out-filename: example.xlsx
|
||||||
|
sheets:
|
||||||
|
- sheet:
|
||||||
|
worksheet-name: "TestSpreadsheet"
|
||||||
|
input-file:
|
||||||
|
- name: input.json
|
||||||
|
data: |
|
||||||
|
jq(.array | {input: . } | tostring )
|
||||||
x-direktiv-secrets:
|
x-direktiv-secrets:
|
||||||
- name: export-xlsxSecret
|
- name: export-xlsxSecret
|
||||||
description: This is a secret value
|
description: This is a secret value
|
||||||
x-direktiv:
|
x-direktiv:
|
||||||
cmds:
|
cmds:
|
||||||
- action: exec
|
- action: foreach
|
||||||
exec: /bin/json2excel -inputJson {{- if eq (deref .Infile) "" }} "input.json" {{- else }} {{ .Infile }} {{- end }} -worksheetName "{{ .WorksheetName }}" -outputFilename '{{ .OutFilename }}'
|
loop: .Sheets
|
||||||
|
#exec: /bin/json2excel -inputJson {{- if eq (deref .Infile) "" }} "input.json" {{- else }} {{ .Infile }} {{- end }} -worksheetName "{{ .WorksheetName }}" -outputFilename '{{ .OutFilename }}'
|
||||||
|
exec: /bin/json2excel -inputJson {{- if eq (deref .Item.Infile) "" }} "input.json" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName "{{ .Item.WorksheetName }}" -outputFilename '{{ .OutFilename }}'
|
||||||
silent: false
|
silent: false
|
||||||
print: true
|
print: true
|
||||||
- action: exec
|
- action: exec
|
||||||
|
Reference in New Issue
Block a user