From 58b5dae5eb4948a3cde238ced1ae05db159749f5 Mon Sep 17 00:00:00 2001 From: xuri Date: Fri, 11 Nov 2022 01:50:07 +0800 Subject: Support update column style when inserting or deleting columns - Go Modules dependencies upgrade - Unify internal variable name - Unit test updated --- sheetpr.go | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) (limited to 'sheetpr.go') 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 } -- cgit v1.2.1