Skip to content

[improvement] Change date format behaviour on error #16

@la-chemin

Description

@la-chemin

It would be better to return the original cell value when apply date format fails, instead of returning error message.

A XLS file is attached that would yield unwanted error message.

testFile.xls

Below is my modifcation

func timeFmtFunc(f string) FmtFunc {
	return func(x *Formatter, v interface{}) string {
		t, ok := v.(time.Time)
		if !ok {
			fval, ok := convertToFloat64(v)
			if !ok {
				return v.(string) // convert it to string
			}
			t = x.ConvertToDate(fval)
		}
		//log.Println("formatting date", t, "with", f, "=", t.Format(f))
		return t.Format(f)
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions