improve handling of empty data
This commit is contained in:
@@ -156,6 +156,24 @@ func main() {
|
|||||||
if len(vslice) < 1 {
|
if len(vslice) < 1 {
|
||||||
// There was no data but lets just log that and close off the empty workbook
|
// 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)
|
fmt.Printf("No data found contained in top-level json key '%s', no work to do.\n", parentNode)
|
||||||
|
|
||||||
|
// Create new file
|
||||||
|
xlsx = createWorkbook(worksheetName, outputFilename)
|
||||||
|
|
||||||
|
// Run code to add column names to the first row of the workbook based off the keyOrder, if defined
|
||||||
|
if len(config.keyOrder) > 0 {
|
||||||
|
|
||||||
|
// Create a slice to hold the values
|
||||||
|
var columnHeadings []string
|
||||||
|
|
||||||
|
// Iterate over the map and append each value to the slice
|
||||||
|
for _, value := range config.keyOrder {
|
||||||
|
columnHeadings = append(columnHeadings, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
createHeadingRow(xlsx, worksheetName, columnHeadings)
|
||||||
|
}
|
||||||
|
|
||||||
// Close off the file
|
// Close off the file
|
||||||
if err := xlsx.SaveAs(outputFilename); err != nil {
|
if err := xlsx.SaveAs(outputFilename); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
Reference in New Issue
Block a user