add some docs
This commit is contained in:
12
README.md
12
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.
|
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
|
## Command line options
|
||||||
| Parameter | Default Value | Description
|
| Parameter | Default Value | Description |
|
||||||
|---------------|---------------|
|
|---------------|---------------|---------------------------|
|
||||||
| worksheetName | Sheet1 | Set the name of the worksheet
|
| 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 |
|
||||||
|
@@ -132,9 +132,10 @@ func main() {
|
|||||||
|
|
||||||
// Set the style for the header values
|
// 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
|
// 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{
|
headerStyle, err2 := xlsx.NewStyle(&excelize.Style{
|
||||||
Font: &excelize.Font{
|
Font: &excelize.Font{
|
||||||
Bold: boldTopRow,
|
Bold: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
@@ -145,9 +146,11 @@ func main() {
|
|||||||
column = 1
|
column = 1
|
||||||
|
|
||||||
// Set the style
|
// Set the style
|
||||||
err = xlsx.SetRowStyle(worksheetName, row, row, headerStyle)
|
if boldTopRow {
|
||||||
if err != nil {
|
err = xlsx.SetRowStyle(worksheetName, row, row, headerStyle)
|
||||||
fmt.Printf("Error setting header style : '%s'\n", err)
|
if err != nil {
|
||||||
|
fmt.Printf("Error setting header style : '%s'\n", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the header row
|
// Add the header row
|
||||||
|
Reference in New Issue
Block a user