Skip to content

Commit

Permalink
Merge pull request #840 from adambaratz/uint-cell
Browse files Browse the repository at this point in the history
Handle unsigned ints
  • Loading branch information
tealeg authored Feb 18, 2025
2 parents e41b457 + 1659caf commit 233ab0f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cell.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ func (c *Cell) SetValue(n interface{}) {
switch t := n.(type) {
case time.Time:
c.SetDateTime(t)
case int, int8, int16, int32, int64:
case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64:
c.SetNumeric(fmt.Sprintf("%d", n))
case float64:
// When formatting floats, do not use fmt.Sprintf("%v", n), this will cause numbers below 1e-4 to be printed in
Expand Down
12 changes: 8 additions & 4 deletions write.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ func (r *Row) WriteSlice(e interface{}, cols int) int {
}
default:
switch val.Kind() { // underlying type of slice
case reflect.String, reflect.Int, reflect.Int8,
reflect.Int16, reflect.Int32, reflect.Int64, reflect.Float64, reflect.Float32:
case reflect.String,
reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,
reflect.Float64, reflect.Float32:
cell := r.AddCell()
cell.SetValue(val.Interface())
case reflect.Bool:
Expand Down Expand Up @@ -153,8 +155,10 @@ func (r *Row) WriteStruct(e interface{}, cols int) int {
}
default:
switch f.Kind() {
case reflect.String, reflect.Int, reflect.Int8,
reflect.Int16, reflect.Int32, reflect.Int64, reflect.Float64, reflect.Float32:
case reflect.String,
reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,
reflect.Float64, reflect.Float32:
cell := r.AddCell()
cell.SetValue(f.Interface())
case reflect.Bool:
Expand Down

0 comments on commit 233ab0f

Please sign in to comment.