func writeHeaderRowToSheet(columns []string, sheet string) error { activeSheet, err := getActiveSheet(sheet) if err != nil { return err } headerFont := xlsx.NewFont(12, "Verdana") headerFont.Bold = true headerFont.Underline = true headerStyle := xlsx.NewStyle() headerStyle.Font = *headerFont var cell *xlsx.Cell row := activeSheet.AddRow() for _, col := range columns { cell = row.AddCell() cell.SetStyle(headerStyle) cell.Value = strings.ToTitle(strings.Replace(col, "_", " ", -1)) } return nil }
func writeFooterRowToSheet(totals []int64, sheet string) error { activeSheet, err := getActiveSheet(sheet) if err != nil { return err } footerFont := xlsx.NewFont(12, "Verdana") footerFont.Bold = true footerStyle := xlsx.NewStyle() footerStyle.Font = *footerFont var cell *xlsx.Cell row := activeSheet.AddRow() cell = row.AddCell() cell.SetStyle(footerStyle) cell.Value = "Total" for i := 1; i < len(totals); i++ { cell = row.AddCell() cell.SetStyle(footerStyle) cell.SetFloatWithFormat(float64(totals[i]), "#,##0") } activeSheet.AddRow() activeSheet.AddRow() return nil }