feat: add filename to exported exceltable
This commit is contained in:
parent
a6e2986143
commit
b1d345b152
4 changed files with 11 additions and 8 deletions
|
|
@ -56,7 +56,7 @@ type TimeEntry struct {
|
|||
Tag string
|
||||
}
|
||||
|
||||
func (t *TimeWarrior) ExportSummary() error {
|
||||
func (t *TimeWarrior) ExportSummary(name string) error {
|
||||
fmt.Println("Export Timetable")
|
||||
exportCommand := exec.Command("timew", "summary", ":year")
|
||||
output, err := exportCommand.Output()
|
||||
|
|
@ -122,7 +122,7 @@ func (t *TimeWarrior) ExportSummary() error {
|
|||
case "break":
|
||||
duration, _ := parseDuration(entry.Duration)
|
||||
summary.BreakDuration += duration
|
||||
case "uni", "free", "krank", "urlaub":
|
||||
case "uni", "free", "krank", "urlaub", "feiertag":
|
||||
summary.Tag = entry.Tag
|
||||
}
|
||||
}
|
||||
|
|
@ -144,7 +144,7 @@ func (t *TimeWarrior) ExportSummary() error {
|
|||
fmt.Printf("%+v\n", entry)
|
||||
}
|
||||
|
||||
err = writeExcelSheet(excelEntries)
|
||||
err = writeExcelSheet(excelEntries, name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -210,7 +210,7 @@ func formatDuration(d time.Duration) string {
|
|||
return fmt.Sprintf("%d:%02d:%02d", h, m, s)
|
||||
}
|
||||
|
||||
func writeExcelSheet(entries []ExcelEntry) error {
|
||||
func writeExcelSheet(entries []ExcelEntry, name string) error {
|
||||
sort.Slice(entries, func(i, j int) bool {
|
||||
dateI, _ := time.Parse("2006-01-02", entries[i].Date)
|
||||
dateJ, _ := time.Parse("2006-01-02", entries[j].Date)
|
||||
|
|
@ -230,7 +230,6 @@ func writeExcelSheet(entries []ExcelEntry) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// Überschriften setzen
|
||||
f.SetCellValue(sheetName, "B1", "Arbeitszeiten "+sheetName)
|
||||
f.SetCellValue(sheetName, "B3", "Datum")
|
||||
f.SetCellValue(sheetName, "D3", "Arbeitszeit")
|
||||
|
|
@ -303,6 +302,8 @@ func writeExcelSheet(entries []ExcelEntry) error {
|
|||
text = "Hochschule"
|
||||
case "urlaub":
|
||||
text = "Urlaub"
|
||||
case "feiertag":
|
||||
text = "Feiertag"
|
||||
default:
|
||||
text = ""
|
||||
}
|
||||
|
|
@ -313,7 +314,7 @@ func writeExcelSheet(entries []ExcelEntry) error {
|
|||
}
|
||||
|
||||
f.SetActiveSheet(index)
|
||||
if err := f.SaveAs("Test.xlsx"); err != nil {
|
||||
if err := f.SaveAs(name); err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue