1
0
mirror of https://github.com/pbnjay/grate.git synced 2024-12-05 03:58:34 +02:00

provide access to format strings

This commit is contained in:
Jeremy Jay 2021-02-23 23:29:20 -05:00
parent a40620db11
commit ebe430dc09
3 changed files with 25 additions and 0 deletions

View File

@ -131,6 +131,19 @@ func (s *Sheet) Types() []string {
return res
}
// Formats extracts the format code for the current record into a list.
func (s *Sheet) Formats() []string {
ok := true
res := make([]string, s.NumCols)
for i, cell := range s.Rows[s.CurRow-1] {
res[i], ok = builtInFormats[cell.FormatNo()]
if !ok {
res[i] = fmt.Sprint(cell.FormatNo())
}
}
return res
}
// Scan extracts values from the current record into the provided arguments
// Arguments must be pointers to one of 5 supported types:
// bool, int64, float64, string, or time.Time

View File

@ -34,6 +34,9 @@ type Collection interface {
// and special cases: "blank", "hyperlink" which are string types
Types() []string
// Formats extracts the format codes for the current record into a list.
Formats() []string
// Scan extracts values from the current record into the provided arguments
// Arguments must be pointers to one of 5 supported types:
// bool, int64, float64, string, or time.Time

View File

@ -44,6 +44,15 @@ func (t *simpleFile) Strings() []string {
return t.rows[t.iterRow]
}
// Formats extracts the format code for the current record into a list.
func (t *simpleFile) Formats() []string {
res := make([]string, len(t.rows[t.iterRow]))
for i := range res {
res[i] = "General"
}
return res
}
// Types extracts the data types from the current record into a list.
// options: "boolean", "integer", "float", "string", "date",
// and special cases: "blank", "hyperlink" which are string types