Browse Source

Removed BestFit

BestFit cannot be used to automatically set column width. Excel does not check for BestFit to change the column width. The column widths have to be set manually.
The only solution is to try and predict the best column width for each column at creation time.
DamianSzkuat 6 years ago
parent
commit
cffc63fca4
4 changed files with 1 additions and 11 deletions
  1. 0 1
      col.go
  2. 0 7
      sheet.go
  3. 0 2
      stream_file_builder.go
  4. 1 1
      stream_style_test.go

+ 0 - 1
col.go

@@ -8,7 +8,6 @@ type Col struct {
 	Max          int
 	Max          int
 	Hidden       bool
 	Hidden       bool
 	Width        float64
 	Width        float64
-	BestFit		 bool
 	Collapsed    bool
 	Collapsed    bool
 	OutlineLevel uint8
 	OutlineLevel uint8
 	numFmt       string
 	numFmt       string

+ 0 - 7
sheet.go

@@ -255,15 +255,9 @@ func (s *Sheet) makeXLSXSheet(refTable *RefTable, styles *xlsxStyleSheet) *xlsxW
 		colsXfIdList[c] = XfId
 		colsXfIdList[c] = XfId
 
 
 		var customWidth bool
 		var customWidth bool
-		// TODO test
-		var bestFit bool
 		if col.Width == 0 {
 		if col.Width == 0 {
 			col.Width = ColWidth
 			col.Width = ColWidth
 			customWidth = false
 			customWidth = false
-			// TODO test
-			if col.BestFit{
-				bestFit = true
-			}
 		} else {
 		} else {
 			customWidth = true
 			customWidth = true
 		}
 		}
@@ -272,7 +266,6 @@ func (s *Sheet) makeXLSXSheet(refTable *RefTable, styles *xlsxStyleSheet) *xlsxW
 				Max:          col.Max,
 				Max:          col.Max,
 				Hidden:       col.Hidden,
 				Hidden:       col.Hidden,
 				Width:        col.Width,
 				Width:        col.Width,
-				BestFit:	  bestFit,
 				CustomWidth:  customWidth,
 				CustomWidth:  customWidth,
 				Collapsed:    col.Collapsed,
 				Collapsed:    col.Collapsed,
 				OutlineLevel: col.OutlineLevel,
 				OutlineLevel: col.OutlineLevel,

+ 0 - 2
stream_file_builder.go

@@ -162,8 +162,6 @@ func (sb *StreamFileBuilder) AddSheetWithStyle(name string, cells []StreamCell)
 	// Set default column types based on the cel types in the first row
 	// Set default column types based on the cel types in the first row
 	for i, cell := range cells {
 	for i, cell := range cells {
 		sheet.Cols[i].SetType(cell.cellType)
 		sheet.Cols[i].SetType(cell.cellType)
-		// TODO test
-		sheet.Cols[i].BestFit = true
 	}
 	}
 	return nil
 	return nil
 }
 }

+ 1 - 1
stream_style_test.go

@@ -10,7 +10,7 @@ import (
 )
 )
 
 
 const (
 const (
-	StyleStreamTestsShouldMakeRealFiles = true
+	StyleStreamTestsShouldMakeRealFiles = false
 )
 )
 
 
 type StreamStyleSuite struct{}
 type StreamStyleSuite struct{}