diff --git a/xls/record/format.go b/xls/record/format.go index fe1ad8f..bbd2384 100644 --- a/xls/record/format.go +++ b/xls/record/format.go @@ -10,6 +10,12 @@ import ( "strings" ) +const ( + DefaultDateFormat = "DD/MM/YYYY" + DefaultTimeFormat = "hh:mm" + DefaultTimeFormatWithSeconds = "hh:mm:ss" +) + //FORMAT: Number Format var FormatRecord = []byte{0x1E, 0x04} //(41Eh) @@ -107,8 +113,14 @@ func (r *Format) GetFormatString(data structure.CellData) string { return fmt.Sprintf("%.f", data.GetFloat64()) } else { t := helpers.TimeFromExcelTime(data.GetFloat64(), false) - dateFormat := strings.ReplaceAll(r.String(), "HH:MM:SS", "hh:mm:ss") - dateFormat = strings.ReplaceAll(dateFormat, "\\", "") + dateStringReplacer := strings.NewReplacer( + "dd/MM/yyyy", DefaultDateFormat, + "HH:mm", DefaultTimeFormat, + "HH:MM:SS", DefaultTimeFormatWithSeconds, + "\\", "", + ) + dateFormat := dateStringReplacer.Replace(r.String()) + return fmtdate.Format(dateFormat, t) } diff --git a/xls/record/labelSst.go b/xls/record/labelSst.go index dd468a3..2ff0830 100644 --- a/xls/record/labelSst.go +++ b/xls/record/labelSst.go @@ -40,7 +40,13 @@ func (r *LabelSSt) GetCol() [2]byte { } func (r *LabelSSt) GetString() string { - return r.sst.Rgb[helpers.BytesToUint32(r.isst[:])].String() + number := helpers.BytesToUint32(r.isst[:]) + + if int(number) < len(r.sst.Rgb) { + return r.sst.Rgb[number].String() + } + + return "" } func (r *LabelSSt) GetFloat64() (fl float64) { @@ -58,9 +64,6 @@ func (r *LabelSSt) GetXFIndex() int { return int(helpers.BytesToUint16(r.ixfe[:])) } - - - func (r *LabelSSt) Read(stream []byte, sst *SST) { r.sst = sst copy(r.rw[:], stream[:2])