@@ -841,10 +841,8 @@ func (fnt *Font) calcTextWidth(text string) float64 {
841841 sz = 11
842842 }
843843 lowerFactor , upperFactor := 1.0 , 1.0
844- if fnt .Family != "" {
845- if fw , ok := supportedFontWidthFactors [strings .ToLower (fnt .Family )]; ok {
846- lowerFactor , upperFactor = fw [0 ], fw [1 ]
847- }
844+ if fw , ok := supportedFontWidthFactors [strings .ToLower (fnt .Family )]; ok {
845+ lowerFactor , upperFactor = fw [0 ], fw [1 ]
848846 }
849847 w := (lowerUnits * lowerFactor + upperUnits * upperFactor + wideUnits ) * (sz / defaultFontSize )
850848 if fnt .Bold {
@@ -906,7 +904,6 @@ func (f *File) autoFitColWidth(sheet string, from, to, rows int, defaultFnt *Fon
906904 return err
907905 }
908906 for col := from ; col <= to ; col ++ {
909- var hasValue bool
910907 var width float64
911908 for row := 1 ; row <= rows ; row ++ {
912909 cell , _ := CoordinatesToCellName (col , row )
@@ -928,7 +925,6 @@ func (f *File) autoFitColWidth(sheet string, from, to, rows int, defaultFnt *Fon
928925 if val == "" {
929926 continue
930927 }
931- hasValue = true
932928 styleID , _ := f .GetCellStyle (sheet , cell )
933929 fnt := defaultFnt
934930 style , err := f .GetStyle (styleID )
@@ -942,16 +938,13 @@ func (f *File) autoFitColWidth(sheet string, from, to, rows int, defaultFnt *Fon
942938 width = w
943939 }
944940 }
945- if hasValue && width > 0 {
941+ if width > 0 {
946942 width += 2
947943 if width > MaxColumnWidth {
948944 width = MaxColumnWidth
949945 }
950946 ws .setColWidth (col , col , width )
951947 }
952- if col == to {
953- break
954- }
955948 }
956949 return nil
957950}
0 commit comments