|
|
@@ -114,18 +114,18 @@ func main() {
|
|
|
|
|
|
|
|
|
|
|
|
// Parse each key into our config struct
|
|
|
|
// Parse each key into our config struct
|
|
|
|
for _, key := range configKeys {
|
|
|
|
for _, key := range configKeys {
|
|
|
|
if strings.EqualFold(key, "key-order") {
|
|
|
|
if strings.EqualFold(key, "keyOrder") {
|
|
|
|
fmt.Printf("Found config element for key-order\n")
|
|
|
|
fmt.Printf("Found config element for keyOrder\n")
|
|
|
|
e, _ := configMap.Get(key)
|
|
|
|
e, _ := configMap.Get(key)
|
|
|
|
for i, e := range strings.Split(e.(string), ",") {
|
|
|
|
for i, e := range strings.Split(e.(string), ",") {
|
|
|
|
config.keyOrder[i] = e
|
|
|
|
config.keyOrder[i] = e
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fmt.Printf("Column order is now : '%v'\n", config.keyOrder)
|
|
|
|
fmt.Printf("Column order is now : '%v'\n", config.keyOrder)
|
|
|
|
} else if strings.EqualFold(key, "overwrite-file") {
|
|
|
|
} else if strings.EqualFold(key, "overwriteFile") {
|
|
|
|
fmt.Printf("Found config element for overwriting output file\n")
|
|
|
|
fmt.Printf("Found config element for overwriting output file\n")
|
|
|
|
e, _ := configMap.Get(key)
|
|
|
|
e, _ := configMap.Get(key)
|
|
|
|
overwriteFile = e.(bool)
|
|
|
|
overwriteFile = e.(bool)
|
|
|
|
} else if strings.EqualFold(key, "parent-node") {
|
|
|
|
} else if strings.EqualFold(key, "parentNode") {
|
|
|
|
fmt.Printf("Found config element for forcing parent key for spreadsheet data\n")
|
|
|
|
fmt.Printf("Found config element for forcing parent key for spreadsheet data\n")
|
|
|
|
e, _ := configMap.Get(key)
|
|
|
|
e, _ := configMap.Get(key)
|
|
|
|
config.parentOverride = e.(string)
|
|
|
|
config.parentOverride = e.(string)
|
|
|
@@ -153,6 +153,16 @@ func main() {
|
|
|
|
// Get an interface that we can work with to access the sub elements
|
|
|
|
// Get an interface that we can work with to access the sub elements
|
|
|
|
vslice := vislice.([]interface{})
|
|
|
|
vslice := vislice.([]interface{})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(vslice) < 1 {
|
|
|
|
|
|
|
|
// There was no data but lets just log that and close off the empty workbook
|
|
|
|
|
|
|
|
fmt.Printf("No data found contained in top-level json key '%s', no work to do.\n", parentNode)
|
|
|
|
|
|
|
|
// Close off the file
|
|
|
|
|
|
|
|
if err := xlsx.SaveAs(outputFilename); err != nil {
|
|
|
|
|
|
|
|
log.Fatal(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Check that the first element is what we expected
|
|
|
|
// Check that the first element is what we expected
|
|
|
|
if _, ok := vslice[0].(orderedmap.OrderedMap); !ok {
|
|
|
|
if _, ok := vslice[0].(orderedmap.OrderedMap); !ok {
|
|
|
|
error := fmt.Sprintf("Type of first vslice element is not an ordered map. It appears to be '%v'\n", reflect.TypeOf(vslice[0]))
|
|
|
|
error := fmt.Sprintf("Type of first vslice element is not an ordered map. It appears to be '%v'\n", reflect.TypeOf(vslice[0]))
|
|
|
|