Browse Source

Fix #101

There is now a broken test; design decision needed. See comment in
cell_test.go.
Shawn Milochik 10 years ago
parent
commit
d2babba81c
2 changed files with 6 additions and 0 deletions
  1. 3 0
      cell.go
  2. 3 0
      cell_test.go

+ 3 - 0
cell.go

@@ -193,6 +193,9 @@ func (c *Cell) formatToInt(format string) string {
 
 // Return the formatted version of the value.
 func (c *Cell) FormattedValue() string {
+	if c.Type() == CellTypeString {
+		return c.Value
+	}
 	var numberFormat string = c.GetNumberFormat()
 	switch numberFormat {
 	case "general":

+ 3 - 0
cell_test.go

@@ -105,6 +105,9 @@ func (l *CellSuite) TestFormattedValue(c *C) {
 	negativeCell.numFmt = "general"
 	c.Assert(negativeCell.FormattedValue(), Equals, "-37947.7500001")
 
+	// TODO: This test is currently broken.  For a string type cell, I
+	// don't think FormattedValue() should be doing a numeric conversion on the value
+	// before returning the string.
 	cell.numFmt = "0"
 	c.Assert(cell.FormattedValue(), Equals, "37947")