-
Notifications
You must be signed in to change notification settings - Fork 385
Closed
Labels
Milestone
Description
Hi,
Thanks for this awesome library, I love it!
I run into a cosmetic issue though, I would like to be able to merge the cells in the footer like I want.
I can do it when the merged columns are first, but not when they're last.
Here is an example:
┌─────────────┬──────────┬───────────────┬─────────┐
│ DEPARTMENT │ DIVISION │ TEAM │ LEAD │
├─────────────┼──────────┼───────────────┼─────────┤
│ Engineering │ Backend │ API Team │ Alice │
│ │ ├───────────────┼─────────┤
│ │ │ Database Team │ Bob │
│ ├──────────┼───────────────┼─────────┤
│ │ Frontend │ UI Team │ Charlie │
├─────────────┼──────────┼───────────────┼─────────┤
│ Marketing │ Digital │ SEO Team │ Dave │
│ │ ├───────────────┼─────────┤
│ │ │ Content Team │ Eve │
├─────────────┴──────────┴───────────────┼─────────┤
│ Total Teams │ 5 │
└────────────────────────────────────────┴─────────┘
the first 2 "empty" columns are getting merged with the first non-empty one table.Footer([]string{"", "", "Total Teams", "5"})
in that example:
┌─────────────┬──────────┬───────────────┬─────────┐
│ DEPARTMENT │ DIVISION │ TEAM │ LEAD │
├─────────────┼──────────┼───────────────┼─────────┤
│ Engineering │ Backend │ API Team │ Alice │
│ │ ├───────────────┼─────────┤
│ │ │ Database Team │ Bob │
│ ├──────────┼───────────────┼─────────┤
│ │ Frontend │ UI Team │ Charlie │
├─────────────┼──────────┼───────────────┼─────────┤
│ Marketing │ Digital │ SEO Team │ Dave │
│ │ ├───────────────┼─────────┤
│ │ │ Content Team │ Eve │
├─────────────┼──────────┼───────────────┼─────────┤
│ Total Teams │ 5 │ │ │
└─────────────┴──────────┴───────────────┴─────────┘
the 3 last columns are not merged at all table.Footer([]string{"Total Teams", "5"})
here is the complete code to reproduce:
package main
import (
"os"
"github.com/olekukonko/tablewriter"
"github.com/olekukonko/tablewriter/renderer"
"github.com/olekukonko/tablewriter/tw"
)
func main() {
data := [][]string{
{"Engineering", "Backend", "API Team", "Alice"},
{"Engineering", "Backend", "Database Team", "Bob"},
{"Engineering", "Frontend", "UI Team", "Charlie"},
{"Marketing", "Digital", "SEO Team", "Dave"},
{"Marketing", "Digital", "Content Team", "Eve"},
}
table := tablewriter.NewTable(os.Stdout,
tablewriter.WithRenderer(renderer.NewBlueprint(tw.Rendition{
Settings: tw.Settings{Separators: tw.Separators{BetweenRows: tw.On}},
})),
tablewriter.WithConfig(tablewriter.Config{
Header: tw.CellConfig{Alignment: tw.CellAlignment{Global: tw.AlignCenter}},
Row: tw.CellConfig{
Formatting: tw.CellFormatting{MergeMode: tw.MergeHierarchical},
Alignment: tw.CellAlignment{Global: tw.AlignLeft},
},
Footer: tw.CellConfig{
Formatting: tw.CellFormatting{
MergeMode: tw.MergeHorizontal,
},
},
}),
)
table.Header([]string{"Department", "Division", "Team", "Lead"})
table.Bulk(data)
table.Footer([]string{"Total Teams", "5"})
table.Render()
}