Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions col.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ type XfRk struct {
func (xf *XfRk) String(wb *WorkBook) string {
idx := int(xf.Index)
if len(wb.Xfs) > idx {
if wb.Xfs[idx] == nil {
return xf.Rk.String()
}
fNo := wb.Xfs[idx].formatNo()
if fNo >= 164 { // user defined format
if formatter := wb.Formats[fNo]; formatter != nil {
Expand Down Expand Up @@ -168,9 +171,13 @@ type NumberCol struct {
}

func (c *NumberCol) String(wb *WorkBook) []string {
if fNo := wb.Xfs[c.Index].formatNo(); fNo != 0 {
t := timeFromExcelTime(c.Float, wb.dateMode == 1)
return []string{yymmdd.Format(t, wb.Formats[fNo].str)}
if int(c.Index) < len(wb.Xfs) && wb.Xfs[c.Index] != nil {
if fNo := wb.Xfs[c.Index].formatNo(); fNo != 0 {
t := timeFromExcelTime(c.Float, wb.dateMode == 1)
if fmtObj := wb.Formats[fNo]; fmtObj != nil {
return []string{yymmdd.Format(t, fmtObj.str)}
}
}
}
return []string{strconv.FormatFloat(c.Float, 'f', -1, 64)}
}
Expand Down Expand Up @@ -218,7 +225,10 @@ type LabelsstCol struct {
}

func (c *LabelsstCol) String(wb *WorkBook) []string {
return []string{wb.sst[int(c.Sst)]}
if int(c.Sst) < len(wb.sst) {
return []string{wb.sst[int(c.Sst)]}
}
return []string{""}
}

type labelCol struct {
Expand Down
8 changes: 8 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module github.com/extrame/xls

go 1.20

require (
github.com/extrame/goyymmdd v0.0.0-20210114090516-7cc815f00d1a
golang.org/x/text v0.30.0
)