This commit is contained in:
@@ -27,7 +27,7 @@ type PostParamsBodySheetsItems struct {
|
||||
InputFile []apps.DirektivFile `json:"input-file"`
|
||||
|
||||
// Label for the worksheet created in the spreadsheet
|
||||
WorksheetName *string `json:"worksheet-name,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this post params body sheets items
|
||||
|
@@ -94,7 +94,7 @@ func init() {
|
||||
"$ref": "#/definitions/direktivFile"
|
||||
}
|
||||
},
|
||||
"worksheet-name": {
|
||||
"name": {
|
||||
"description": "Label for the worksheet created in the spreadsheet",
|
||||
"type": "string",
|
||||
"default": "Sheet1"
|
||||
@@ -141,7 +141,7 @@ func init() {
|
||||
"cmds": [
|
||||
{
|
||||
"action": "foreach",
|
||||
"exec": "/bin/json2excel -inputJson {{- if eq (deref .Item.Infile) \"\" }} \"input.json\" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName \"{{ .Item.WorksheetName }}\" -outputFilename '{{ .OutFilename }}'",
|
||||
"exec": "/bin/json2excel -inputJson {{- if eq (deref .Item.Infile) \"\" }} \"input.json\" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName \"{{ .Item.Name }}\" -outputFilename '{{ .OutFilename }}'",
|
||||
"loop": ".Sheets",
|
||||
"print": true,
|
||||
"silent": false
|
||||
@@ -160,11 +160,11 @@ func init() {
|
||||
},
|
||||
"x-direktiv-examples": [
|
||||
{
|
||||
"content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx\n sheets:\n - sheet:\n worksheet-name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.input)",
|
||||
"content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx\n sheets:\n - name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.input)",
|
||||
"title": "Basic"
|
||||
},
|
||||
{
|
||||
"content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx \n sheets:\n - sheet:\n worksheet-name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.array | {input: . } | tostring ) ",
|
||||
"content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx \n sheets:\n - name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.array | {input: . } | tostring ) ",
|
||||
"title": "Use jq to add a parent key 'input' containing array of objects"
|
||||
}
|
||||
],
|
||||
@@ -305,7 +305,7 @@ func init() {
|
||||
"cmds": [
|
||||
{
|
||||
"action": "foreach",
|
||||
"exec": "/bin/json2excel -inputJson {{- if eq (deref .Item.Infile) \"\" }} \"input.json\" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName \"{{ .Item.WorksheetName }}\" -outputFilename '{{ .OutFilename }}'",
|
||||
"exec": "/bin/json2excel -inputJson {{- if eq (deref .Item.Infile) \"\" }} \"input.json\" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName \"{{ .Item.Name }}\" -outputFilename '{{ .OutFilename }}'",
|
||||
"loop": ".Sheets",
|
||||
"print": true,
|
||||
"silent": false
|
||||
@@ -324,11 +324,11 @@ func init() {
|
||||
},
|
||||
"x-direktiv-examples": [
|
||||
{
|
||||
"content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx\n sheets:\n - sheet:\n worksheet-name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.input)",
|
||||
"content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx\n sheets:\n - name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.input)",
|
||||
"title": "Basic"
|
||||
},
|
||||
{
|
||||
"content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx \n sheets:\n - sheet:\n worksheet-name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.array | {input: . } | tostring ) ",
|
||||
"content": "- id: export-xlsx\n type: action\n action:\n function: export-xlsx\n input: \n out-filename: example.xlsx \n sheets:\n - name: \"TestSpreadsheet\"\n input-file:\n - name: input.json\n data: |\n jq(.array | {input: . } | tostring ) ",
|
||||
"title": "Use jq to add a parent key 'input' containing array of objects"
|
||||
}
|
||||
],
|
||||
@@ -431,7 +431,7 @@ func init() {
|
||||
"$ref": "#/definitions/direktivFile"
|
||||
}
|
||||
},
|
||||
"worksheet-name": {
|
||||
"name": {
|
||||
"description": "Label for the worksheet created in the spreadsheet",
|
||||
"type": "string",
|
||||
"default": "Sheet1"
|
||||
|
@@ -185,7 +185,7 @@ func runCommand0(ctx context.Context,
|
||||
params.DirektivDir,
|
||||
}
|
||||
|
||||
cmd, err := templateString(`/bin/json2excel -inputJson {{- if eq (deref .Item.Infile) "" }} "input.json" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName "{{ .Item.WorksheetName }}" -outputFilename '{{ .OutFilename }}'`, ls)
|
||||
cmd, err := templateString(`/bin/json2excel -inputJson {{- if eq (deref .Item.Infile) "" }} "input.json" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName "{{ .Item.Name }}" -outputFilename '{{ .OutFilename }}'`, ls)
|
||||
if err != nil {
|
||||
ir := make(map[string]interface{})
|
||||
ir[successKey] = false
|
||||
|
16
readme.md
16
readme.md
@@ -33,12 +33,11 @@ functions:
|
||||
input:
|
||||
out-filename: example.xlsx
|
||||
sheets:
|
||||
- sheet:
|
||||
worksheet-name: "TestSpreadsheet"
|
||||
input-file:
|
||||
- name: input.json
|
||||
data: |
|
||||
jq(.input)
|
||||
- name: "TestSpreadsheet"
|
||||
input-file:
|
||||
- name: input.json
|
||||
data: |
|
||||
jq(.input)
|
||||
```
|
||||
#### Use jq to add a parent key 'input' containing array of objects
|
||||
```yaml
|
||||
@@ -49,8 +48,7 @@ functions:
|
||||
input:
|
||||
out-filename: example.xlsx
|
||||
sheets:
|
||||
- sheet:
|
||||
worksheet-name: "TestSpreadsheet"
|
||||
- name: "TestSpreadsheet"
|
||||
input-file:
|
||||
- name: input.json
|
||||
data: |
|
||||
@@ -135,6 +133,6 @@ functions:
|
||||
|------|------|---------|:--------:| ------- |-------------|---------|
|
||||
| infile | string| `string` | | | Name of the json input file to utilise | |
|
||||
| input-file | [][DirektivFile](#direktiv-file)| `[]apps.DirektivFile` | | | File to create before running commands | |
|
||||
| worksheet-name | string| `string` | | `"Sheet1"`| Label for the worksheet created in the spreadsheet | |
|
||||
| name | string| `string` | | `"Sheet1"`| Label for the worksheet created in the spreadsheet | |
|
||||
|
||||
|
||||
|
18
swagger.yaml
18
swagger.yaml
@@ -68,7 +68,7 @@ paths:
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
worksheet-name:
|
||||
name:
|
||||
type: string
|
||||
description: Label for the worksheet created in the spreadsheet
|
||||
default: "Sheet1"
|
||||
@@ -98,12 +98,11 @@ paths:
|
||||
input:
|
||||
out-filename: example.xlsx
|
||||
sheets:
|
||||
- sheet:
|
||||
worksheet-name: "TestSpreadsheet"
|
||||
input-file:
|
||||
- name: input.json
|
||||
data: |
|
||||
jq(.input)
|
||||
- name: "TestSpreadsheet"
|
||||
input-file:
|
||||
- name: input.json
|
||||
data: |
|
||||
jq(.input)
|
||||
- title: Use jq to add a parent key 'input' containing array of objects
|
||||
content: |-
|
||||
- id: export-xlsx
|
||||
@@ -113,8 +112,7 @@ paths:
|
||||
input:
|
||||
out-filename: example.xlsx
|
||||
sheets:
|
||||
- sheet:
|
||||
worksheet-name: "TestSpreadsheet"
|
||||
- name: "TestSpreadsheet"
|
||||
input-file:
|
||||
- name: input.json
|
||||
data: |
|
||||
@@ -127,7 +125,7 @@ paths:
|
||||
- action: foreach
|
||||
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 }}'
|
||||
exec: /bin/json2excel -inputJson {{- if eq (deref .Item.Infile) "" }} "input.json" {{- else }} {{ .Item.Infile }} {{- end }} -worksheetName "{{ .Item.Name }}" -outputFilename '{{ .OutFilename }}'
|
||||
silent: false
|
||||
print: true
|
||||
- action: exec
|
||||
|
Reference in New Issue
Block a user