summaryrefslogtreecommitdiff
path: root/sheetpr.go
diff options
context:
space:
mode:
authorxuri <xuri.me@gmail.com>2022-11-11 01:50:07 +0800
committerxuri <xuri.me@gmail.com>2022-11-11 01:50:07 +0800
commit58b5dae5eb4948a3cde238ced1ae05db159749f5 (patch)
treeea265793558433a3f0a143bb7aa7f408eafd7408 /sheetpr.go
parent8753950d62c150034a919599a7762cef19035552 (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.go26
1 files changed, 6 insertions, 20 deletions
diff --git a/sheetpr.go b/sheetpr.go
index 73a76a9..41ca082 100644
--- a/sheetpr.go
+++ b/sheetpr.go
@@ -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
}