Browse Source

Revert "Revert "Set default cell type to CellTypeGeneral""

This reverts commit 293d6d510e9e6523ee2603417bb650d711bc8beb.
blackss2 10 years ago
parent
commit
79e5158afd
2 changed files with 5 additions and 1 deletions
  1. 1 1
      cell.go
  2. 4 0
      sheet_test.go

+ 1 - 1
cell.go

@@ -46,7 +46,7 @@ type CellInterface interface {
 
 // NewCell creates a cell and adds it to a row.
 func NewCell(r *Row) *Cell {
-	return &Cell{Row: r}
+	return &Cell{Row: r, cellType: CellTypeGeneral}
 }
 
 // Merge with other cells, horizontally and/or vertically.

+ 4 - 0
sheet_test.go

@@ -26,6 +26,7 @@ func (s *SheetSuite) TestMakeXLSXSheetFromRows(c *C) {
 	sheet := file.AddSheet("Sheet1")
 	row := sheet.AddRow()
 	cell := row.AddCell()
+	cell.cellType = CellTypeString
 	cell.Value = "A cell!"
 	refTable := NewSharedStringRefTable()
 	styles := newXlsxStyleSheet(nil)
@@ -191,6 +192,7 @@ func (s *SheetSuite) TestMarshalSheet(c *C) {
 	row := sheet.AddRow()
 	cell := row.AddCell()
 	cell.Value = "A cell!"
+	cell.cellType = CellTypeString
 	refTable := NewSharedStringRefTable()
 	styles := newXlsxStyleSheet(nil)
 	xSheet := sheet.makeXLSXSheet(refTable, styles)
@@ -211,8 +213,10 @@ func (s *SheetSuite) TestMarshalSheetWithMultipleCells(c *C) {
 	sheet := file.AddSheet("Sheet1")
 	row := sheet.AddRow()
 	cell := row.AddCell()
+	cell.cellType = CellTypeString
 	cell.Value = "A cell (with value 1)!"
 	cell = row.AddCell()
+	cell.cellType = CellTypeString
 	cell.Value = "A cell (with value 2)!"
 	refTable := NewSharedStringRefTable()
 	styles := newXlsxStyleSheet(nil)