diff options
author | xuri <xuri.me@gmail.com> | 2022-11-11 01:50:07 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2022-11-11 01:50:07 +0800 |
commit | 58b5dae5eb4948a3cde238ced1ae05db159749f5 (patch) | |
tree | ea265793558433a3f0a143bb7aa7f408eafd7408 /sheetpr.go | |
parent | 8753950d62c150034a919599a7762cef19035552 (diff) |
Support update column style when inserting or deleting columns
- Go Modules dependencies upgrade
- Unify internal variable name
- Unit test updated
Diffstat (limited to 'sheetpr.go')
-rw-r--r-- | sheetpr.go | 26 |
1 files changed, 6 insertions, 20 deletions
@@ -163,26 +163,12 @@ func (f *File) SetSheetProps(sheet string, opts *SheetPropsOptions) error { if ws.SheetFormatPr == nil { ws.SheetFormatPr = &xlsxSheetFormatPr{DefaultRowHeight: defaultRowHeight} } - if opts.BaseColWidth != nil { - ws.SheetFormatPr.BaseColWidth = *opts.BaseColWidth - } - if opts.DefaultColWidth != nil { - ws.SheetFormatPr.DefaultColWidth = *opts.DefaultColWidth - } - if opts.DefaultRowHeight != nil { - ws.SheetFormatPr.DefaultRowHeight = *opts.DefaultRowHeight - } - if opts.CustomHeight != nil { - ws.SheetFormatPr.CustomHeight = *opts.CustomHeight - } - if opts.ZeroHeight != nil { - ws.SheetFormatPr.ZeroHeight = *opts.ZeroHeight - } - if opts.ThickTop != nil { - ws.SheetFormatPr.ThickTop = *opts.ThickTop - } - if opts.ThickBottom != nil { - ws.SheetFormatPr.ThickBottom = *opts.ThickBottom + s := reflect.ValueOf(opts).Elem() + for i := 11; i < 18; i++ { + if !s.Field(i).IsNil() { + name := s.Type().Field(i).Name + reflect.ValueOf(ws.SheetFormatPr).Elem().FieldByName(name).Set(s.Field(i).Elem()) + } } return err } |