do formatting to heading row of empty worksheet
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

This commit is contained in:
2024-06-28 09:19:25 +10:00
parent bfa2afbb6c
commit d5a803644b

View File

@@ -162,16 +162,35 @@ func main() {
// 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)
headerStyle, err := xlsx.NewStyle(&excelize.Style{
Font: &excelize.Font{
Bold: true,
},
})
if err != nil {
fmt.Printf("Error generating header style : '%s'\n", err)
} else {
// Set the style if there was no error generating it
if boldTopRow {
err = xlsx.SetRowStyle(worksheetName, 1, 1, headerStyle)
if err != nil {
fmt.Printf("Error setting header style : '%s'\n", err)
}
}
}
if autoWidth {
err = SetColAutoWidth(xlsx, worksheetName)
if err != nil {
fmt.Printf("Error setting auto width : '%s'\n", err)
}
}
}
// Close off the file
@@ -224,15 +243,15 @@ func main() {
})
if err2 != nil {
fmt.Printf("Error generating header style : '%s'\n", err2)
}
// Set the style
} else {
// Set the style if there was no error generating it
if boldTopRow {
err = xlsx.SetRowStyle(worksheetName, 1, 1, headerStyle)
if err != nil {
fmt.Printf("Error setting header style : '%s'\n", err)
}
}
}
// Freeze top row if requested, see https://xuri.me/excelize/en/utils.html#SetPanes
if freezeTopRow {