From 061bb83861c377478bccbf1297e676fe2a5da97a Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Mon, 13 Feb 2023 12:40:56 +1100 Subject: [PATCH] add some docs --- README.md | 12 +++++++++--- cmd/main/main.go | 11 +++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 0b0daa0..105875e 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,12 @@ This is a basic utility to take json and convert it into an OpenXml format xlsx It expects that the json input is formatted as an object containing an array of objects. Column names are generated based on the keys in the first nested object. ## Command line options -| Parameter | Default Value | Description -|---------------|---------------| -| worksheetName | Sheet1 | Set the name of the worksheet +| Parameter | Default Value | Description | +|---------------|---------------|---------------------------| +| inputJson | input.json | File path of the input json to process | +| outputFilename | output.xlsx | File path of the output file | +| worksheetName | Sheet1 | Set the name of the worksheet | +| boldTopRow | true | Sets the top row of the worksheet to bold | +| freezeTopRow | true | Freezes the first row of the Excel worksheet | +| autofilter | true | Sets the auto filter on the first row | +| autowidth | true | Automatically set the column width to fit contents | diff --git a/cmd/main/main.go b/cmd/main/main.go index 4020527..83979b9 100644 --- a/cmd/main/main.go +++ b/cmd/main/main.go @@ -132,9 +132,10 @@ func main() { // Set the style for the header values // Just handling bold for now but we can do other styles too as per https://xuri.me/excelize/en/style.html#NewStyle + fmt.Printf("Bolding top row : %v\n", boldTopRow) headerStyle, err2 := xlsx.NewStyle(&excelize.Style{ Font: &excelize.Font{ - Bold: boldTopRow, + Bold: true, }, }) if err2 != nil { @@ -145,9 +146,11 @@ func main() { column = 1 // Set the style - err = xlsx.SetRowStyle(worksheetName, row, row, headerStyle) - if err != nil { - fmt.Printf("Error setting header style : '%s'\n", err) + if boldTopRow { + err = xlsx.SetRowStyle(worksheetName, row, row, headerStyle) + if err != nil { + fmt.Printf("Error setting header style : '%s'\n", err) + } } // Add the header row