Shawn Milochik 10 years ago
parent
commit
330db4d7cc
5 changed files with 75 additions and 75 deletions
  1. 6 6
      file_test.go
  2. 56 56
      lib.go
  3. 7 7
      sheet.go
  4. 3 3
      theme.go
  5. 3 3
      xmlStyle.go

+ 6 - 6
file_test.go

@@ -775,10 +775,10 @@ func (s *SliceReaderSuite) TestFileWithEmptyRows(c *C) {
 }
 
 func (s *SliceReaderSuite) TestFileWithEmptyCols(c *C) {
-  f, err := OpenFile("./testdocs/empty_rows.xlsx")
-  c.Assert(err, IsNil)
-  sheet, ok := f.Sheet["EmptyCols"]
-  c.Assert(ok, Equals, true)
-  c.Assert(sheet.Cell(0, 0).String(), Equals, "")
-  c.Assert(sheet.Cell(0, 2).String(), Equals, "C1")
+	f, err := OpenFile("./testdocs/empty_rows.xlsx")
+	c.Assert(err, IsNil)
+	sheet, ok := f.Sheet["EmptyCols"]
+	c.Assert(ok, Equals, true)
+	c.Assert(sheet.Cell(0, 0).String(), Equals, "")
+	c.Assert(sheet.Cell(0, 2).String(), Equals, "C1")
 }

+ 56 - 56
lib.go

@@ -312,65 +312,65 @@ func makeEmptyRow() *Row {
 }
 
 type sharedFormula struct {
-   x, y    int
-   formula string
+	x, y    int
+	formula string
 }
 
 func formulaForCell(rawcell xlsxC, sharedFormulas map[int]sharedFormula) string {
-   var res string
-
-   f := rawcell.F
-   if f.T == "shared" {
-	   x, y, err := getCoordsFromCellIDString(rawcell.R)
-	   if err != nil {
-		   res = f.Content
-	   } else {
-		   if f.Ref != "" {
-			   res = f.Content
-			   sharedFormulas[f.Si] = sharedFormula{x, y, res}
-		   } else {
-			   sharedFormula := sharedFormulas[f.Si]
-			   dx := x - sharedFormula.x
-			   dy := y - sharedFormula.y
-			   orig := []byte(sharedFormula.formula)
-			   var start, end int
-			   for end = 0; end < len(orig); end++ {
-				   c := orig[end]
-				   if c >= 'A' && c <= 'Z' {
-					   res += string(orig[start:end])
-					   start = end
-					   end++
-					   foundNum := false
-					   for ; end < len(orig); end++ {
-						   idc := orig[end]
-						   if idc >= '0' && idc <= '9' {
-							   foundNum = true
-						   } else if idc >= 'A' && idc <= 'Z' {
-							   if foundNum {
-								   break
-							   }
-						   } else {
-							   break
-						   }
-					   }
-					   if foundNum {
-						   fx, fy, _ := getCoordsFromCellIDString(string(orig[start:end]))
-						   fx += dx
-						   fy += dy
-						   res += getCellIDStringFromCoords(fx, fy)
-						   start = end
-					   }
-				   }
-			   }
-			   if start < len(orig) {
-				   res += string(orig[start:end])
-			   }
-		   }
-	   }
-   } else {
-	   res = f.Content
-   }
-   return strings.Trim(res, " \t\n\r")
+	var res string
+
+	f := rawcell.F
+	if f.T == "shared" {
+		x, y, err := getCoordsFromCellIDString(rawcell.R)
+		if err != nil {
+			res = f.Content
+		} else {
+			if f.Ref != "" {
+				res = f.Content
+				sharedFormulas[f.Si] = sharedFormula{x, y, res}
+			} else {
+				sharedFormula := sharedFormulas[f.Si]
+				dx := x - sharedFormula.x
+				dy := y - sharedFormula.y
+				orig := []byte(sharedFormula.formula)
+				var start, end int
+				for end = 0; end < len(orig); end++ {
+					c := orig[end]
+					if c >= 'A' && c <= 'Z' {
+						res += string(orig[start:end])
+						start = end
+						end++
+						foundNum := false
+						for ; end < len(orig); end++ {
+							idc := orig[end]
+							if idc >= '0' && idc <= '9' {
+								foundNum = true
+							} else if idc >= 'A' && idc <= 'Z' {
+								if foundNum {
+									break
+								}
+							} else {
+								break
+							}
+						}
+						if foundNum {
+							fx, fy, _ := getCoordsFromCellIDString(string(orig[start:end]))
+							fx += dx
+							fy += dy
+							res += getCellIDStringFromCoords(fx, fy)
+							start = end
+						}
+					}
+				}
+				if start < len(orig) {
+					res += string(orig[start:end])
+				}
+			}
+		}
+	} else {
+		res = f.Content
+	}
+	return strings.Trim(res, " \t\n\r")
 }
 
 // fillCellData attempts to extract a valid value, usable in

+ 7 - 7
sheet.go

@@ -8,13 +8,13 @@ import (
 // Sheet is a high level structure intended to provide user access to
 // the contents of a particular sheet within an XLSX file.
 type Sheet struct {
-	Name   string
-	File   *File
-	Rows   []*Row
-	Cols   []*Col
-	MaxRow int
-	MaxCol int
-	Hidden bool
+	Name       string
+	File       *File
+	Rows       []*Row
+	Cols       []*Col
+	MaxRow     int
+	MaxCol     int
+	Hidden     bool
 	SheetViews []SheetView
 }
 

+ 3 - 3
theme.go

@@ -22,8 +22,8 @@ func newTheme(themeXml xlsxTheme) *theme {
 		clrMap[scheme.XMLName.Local] = rgbColor
 	}
 	colors := []string{clrMap["lt1"], clrMap["dk1"], clrMap["lt2"], clrMap["dk2"], clrMap["accent1"],
-					   clrMap["accent2"], clrMap["accent3"], clrMap["accent4"], clrMap["accent5"],
-					   clrMap["accent6"], clrMap["hlink"], clrMap["folHlink"]}
+		clrMap["accent2"], clrMap["accent3"], clrMap["accent4"], clrMap["accent5"],
+		clrMap["accent6"], clrMap["hlink"], clrMap["folHlink"]}
 	return &theme{colors}
 }
 
@@ -39,7 +39,7 @@ func (t *theme) themeColor(index int64, tint float64) string {
 		if tint < 0 {
 			l *= (1 + tint)
 		} else {
-			l = l*(1 - tint) + (1 - (1 - tint))
+			l = l*(1-tint) + (1 - (1 - tint))
 		}
 		br, bg, bb := HSLToRGB(h, s, l)
 		return fmt.Sprintf("FF%02X%02X%02X", br, bg, bb)

+ 3 - 3
xmlStyle.go

@@ -29,10 +29,10 @@ type xlsxStyleSheet struct {
 	CellXfs      xlsxCellXfs      `xml:"cellXfs,omitempty"`
 	NumFmts      xlsxNumFmts      `xml:"numFmts,omitempty"`
 
-	theme      *theme
-	styleCache map[int]*Style // `-`
+	theme          *theme
+	styleCache     map[int]*Style     // `-`
 	numFmtRefTable map[int]xlsxNumFmt `xml:"-"`
-	lock       *sync.RWMutex
+	lock           *sync.RWMutex
 }
 
 func newXlsxStyleSheet(t *theme) *xlsxStyleSheet {