Browse Source

Mostly refactoring

DamianSzkuat 6 years ago
parent
commit
697c3d3985
8 changed files with 132 additions and 167 deletions
  1. 1 2
      .gitignore
  2. 1 14
      row.go
  3. 10 10
      stream_cell.go
  4. 12 12
      stream_file.go
  5. 14 19
      stream_file_builder.go
  6. 0 1
      stream_style.go
  7. 94 94
      stream_style_test.go
  8. 0 15
      write.go

+ 1 - 2
.gitignore

@@ -3,5 +3,4 @@
 .DS_Store
 xlsx.test
 *.swp
-coverage.txt
-.idea
+coverage.txt

+ 1 - 14
row.go

@@ -24,17 +24,4 @@ func (r *Row) AddCell() *Cell {
 	r.Cells = append(r.Cells, cell)
 	r.Sheet.maybeAddCol(len(r.Cells))
 	return cell
-}
-
-// AddStreamCell takes as input a StreamCell, creates a new Cell from it,
-// and appends the new cell to the row.
-func (r *Row) AddStreamCell(streamCell StreamCell) {
-	cell := NewCell(r)
-	cell.Value = streamCell.cellData
-	cell.style = streamCell.cellStyle.style
-	cell.NumFmt = builtInNumFmt[streamCell.cellStyle.xNumFmtId]
-	cell.cellType = streamCell.cellType
-	r.Cells = append(r.Cells, cell)
-	// TODO
-	r.Sheet.maybeAddCol(len(r.Cells))
-}
+}

+ 10 - 10
stream_cell.go

@@ -21,31 +21,31 @@ func NewStreamCell(cellData string, cellStyle StreamStyle, cellType CellType) St
 	}
 }
 
-// MakeStringStreamCell creates a new cell that holds string data, is of type string and uses general formatting
-func MakeStringStreamCell(cellData string) StreamCell {
+// NewStringStreamCell creates a new cell that holds string data, is of type string and uses general formatting
+func NewStringStreamCell(cellData string) StreamCell {
 	return NewStreamCell(cellData, Strings, CellTypeString)
 }
 
-// MakeStyledStringStreamCell creates a new cell that holds a string and is styled according to the given style
-func MakeStyledStringStreamCell(cellData string, cellStyle StreamStyle) StreamCell {
+// NewStyledStringStreamCell creates a new cell that holds a string and is styled according to the given style
+func NewStyledStringStreamCell(cellData string, cellStyle StreamStyle) StreamCell {
 	return NewStreamCell(cellData, cellStyle, CellTypeString)
 }
 
-// MakeIntegerStreamCell creates a new cell that holds an integer value (represented as string),
+// NewIntegerStreamCell creates a new cell that holds an integer value (represented as string),
 // is formatted as a standard integer and is of type numeric.
-func MakeIntegerStreamCell(cellData int) StreamCell {
+func NewIntegerStreamCell(cellData int) StreamCell {
 	return NewStreamCell(strconv.Itoa(cellData), Integers, CellTypeNumeric)
 }
 
-// MakeStyledIntegerStreamCell creates a new cell that holds an integer value (represented as string)
+// NewStyledIntegerStreamCell creates a new cell that holds an integer value (represented as string)
 // and is styled according to the given style.
-func MakeStyledIntegerStreamCell(cellData int, cellStyle StreamStyle) StreamCell {
+func NewStyledIntegerStreamCell(cellData int, cellStyle StreamStyle) StreamCell {
 	return NewStreamCell(strconv.Itoa(cellData), cellStyle, CellTypeNumeric)
 }
 
-// MakeDateStreamCell creates a new cell that holds a date value and is formatted as dd-mm-yyyy and
+// NewDateStreamCell creates a new cell that holds a date value and is formatted as dd-mm-yyyy and
 // and is of type numeric
-func MakeDateStreamCell(t time.Time) StreamCell {
+func NewDateStreamCell(t time.Time) StreamCell {
 	excelTime := TimeToExcelTime(t, false)
 	return NewStreamCell(strconv.Itoa(int(excelTime)), Dates, CellTypeNumeric)
 }

+ 12 - 12
stream_file.go

@@ -53,15 +53,15 @@ func (sf *StreamFile) Write(cells []string) error {
 	return sf.zipWriter.Flush()
 }
 
-// WriteWithStyle will write a row of cells to the current sheet. Every call to WriteWithStyle on the same sheet must
-// contain the same number of cells as the header provided when the sheet was created or an error will be returned.
-// This function will always trigger a flush on success. WriteWithStyle supports all data types and styles that
-// are supported by StreamCell.
-func (sf *StreamFile) WriteWithStyle(cells []StreamCell) error {
+// WriteS will write a row of cells to the current sheet. Every call to WriteS on the same sheet must
+// contain the same number of cells as the number of columns provided when the sheet was created or an error
+// will be returned. This function will always trigger a flush on success. WriteS supports all data types
+// and styles that are supported by StreamCell.
+func (sf *StreamFile) WriteS(cells []StreamCell) error {
 	if sf.err != nil {
 		return sf.err
 	}
-	err := sf.writeWithStyle(cells)
+	err := sf.writeS(cells)
 	if err != nil {
 		sf.err = err
 		return err
@@ -83,15 +83,15 @@ func (sf *StreamFile) WriteAll(records [][]string) error {
 	return sf.zipWriter.Flush()
 }
 
-// WriteAllWithStyle will write all the rows provided in records. All rows must have the same number of cells as
-// the headers. This function will always trigger a flush on success. WriteWithStyle supports all data types and
-// styles that are supported by StreamCell.
-func (sf *StreamFile) WriteAllWithStyle(records [][]StreamCell) error {
+// WriteAllS will write all the rows provided in records. All rows must have the same number of cells as
+// the number of columns given when creating the sheet. This function will always trigger a flush on success.
+// WriteS supports all data types and styles that are supported by StreamCell.
+func (sf *StreamFile) WriteAllS(records [][]StreamCell) error {
 	if sf.err != nil {
 		return sf.err
 	}
 	for _, row := range records {
-		err := sf.writeWithStyle(row)
+		err := sf.writeS(row)
 		if err != nil {
 			sf.err = err
 			return err
@@ -147,7 +147,7 @@ func (sf *StreamFile) write(cells []string) error {
 	return sf.zipWriter.Flush()
 }
 
-func (sf *StreamFile) writeWithStyle(cells []StreamCell) error {
+func (sf *StreamFile) writeS(cells []StreamCell) error {
 	if sf.currentSheet == nil {
 		return NoCurrentSheetError
 	}

+ 14 - 19
stream_file_builder.go

@@ -125,11 +125,12 @@ func (sb *StreamFileBuilder) AddSheet(name string, headers []string, cellTypes [
 	return nil
 }
 
-// AddSheetWithStyle will add a sheet with the given name and column styles. The number of column styles given
-// is the number of columns that will be created, and thus the number of cell each row has to have.
+// AddSheetS will add a sheet with the given name and column styles. The number of column styles given
+// is the number of columns that will be created, and thus the number of cells each row has to have.
 // columnStyles[0] becomes the style of the first column, columnStyles[1] the style of the second column etc.
-// Sheet names must be unique, or an error will be thrown.
-func (sb *StreamFileBuilder) AddSheetWithStyle(name string, columnStyles []StreamStyle) error {
+// All the styles in columnStyles have to have been added or an error will be returned.
+// Sheet names must be unique, or an error will be returned.
+func (sb *StreamFileBuilder) AddSheetS(name string, columnStyles []StreamStyle) error {
 	if sb.built {
 		return BuiltStreamFileBuilderError
 	}
@@ -142,7 +143,7 @@ func (sb *StreamFileBuilder) AddSheetWithStyle(name string, columnStyles []Strea
 	// To make sure no new styles can be added after adding a sheet
 	sb.firstSheetAdded = true
 
-	// Check if all styles in the headers have been created
+	// Check if all styles that will be used for columns have been created
 	for _, colStyle := range columnStyles {
 		if _, ok := sb.customStreamStyles[colStyle]; !ok {
 			return errors.New("trying to make use of a style that has not been added")
@@ -152,16 +153,11 @@ func (sb *StreamFileBuilder) AddSheetWithStyle(name string, columnStyles []Strea
 	// TODO Is needed for stream file to work but is not needed for streaming with styles
 	sb.styleIds = append(sb.styleIds, []int{})
 
-	// Set the values of the first row and the the number of columns
-	//row := sheet.AddRow()
-	//if count := row.WriteCellSlice(cells, -1); count != len(cells) {
-	//	// Set built on error so that all subsequent calls to the builder will also fail.
-	//	sb.built = true
-	//	return errors.New("failed to write headers")
-	//}
 	sheet.maybeAddCol(len(columnStyles))
 
-	// Set default column types based on the cel types in the first row
+	// Set default column styles based on the cel styles in the first row
+	// Set the default column width to 11. This makes enough places for the
+	// default date style cells to display the dates correctly
 	for i, colStyle := range columnStyles {
 		sheet.Cols[i].SetStreamStyle(colStyle)
 		sheet.Cols[i].Width = 11
@@ -228,7 +224,6 @@ func (sb *StreamFileBuilder) marshalStyles() (string, error) {
 		// TODO do not add styles that already exist
 		XfId := handleStyleForXLSX(streamStyle.style, streamStyle.xNumFmtId, sb.xlsxFile.styles)
 		sb.styleIdMap[streamStyle] = XfId
-		// sb.customStylesAdded = true
 	}
 
 	styleSheetXMLString, err := sb.xlsxFile.styles.Marshal()
@@ -240,8 +235,8 @@ func (sb *StreamFileBuilder) marshalStyles() (string, error) {
 
 // AddStreamStyle adds a new style to the style sheet.
 // Only Styles that have been added through this function will be usable.
-// This function cannot be used after AddSheetWithStyle or Build has been called, and if it is
-// called after AddSheetWithStyle or Buildit will return an error.
+// This function cannot be used after AddSheetS or Build has been called, and if it is
+// called after AddSheetS or Buildit will return an error.
 func (sb *StreamFileBuilder) AddStreamStyle(streamStyle StreamStyle) error {
 	if sb.firstSheetAdded {
 		return errors.New("at least one sheet has been added, cannot add new styles anymore")
@@ -256,8 +251,8 @@ func (sb *StreamFileBuilder) AddStreamStyle(streamStyle StreamStyle) error {
 
 // AddStreamStyleList adds a list of new styles to the style sheet.
 // Only Styles that have been added through either this function or AddStreamStyle will be usable.
-// This function cannot be used after AddSheetWithStyle and Build has been called, and if it is
-// called after AddSheetWithStyle and Build it will return an error.
+// This function cannot be used after AddSheetS and Build has been called, and if it is
+// called after AddSheetS and Build it will return an error.
 func (sb *StreamFileBuilder) AddStreamStyleList(streamStyles []StreamStyle) error {
 	for _, streamStyle := range streamStyles {
 		err := sb.AddStreamStyle(streamStyle)
@@ -317,7 +312,7 @@ func getSheetIndex(sf *StreamFile, path string) (int, error) {
 // removeDimensionTag will return the passed in XLSX Spreadsheet XML with the dimension tag removed.
 // data is the XML data for the sheet
 // sheet is the Sheet struct that the XML was created from.
-// Can return an error if the XML's dimension tag does not match was is expected based on the provided Sheet
+// Can return an error if the XML's dimension tag does not match what is expected based on the provided Sheet
 func removeDimensionTag(data string, sheet *Sheet) (string, error) {
 	x := len(sheet.Cols) - 1
 	y := len(sheet.Rows) - 1

+ 0 - 1
stream_style.go

@@ -90,7 +90,6 @@ func MakeStyle(formatStyleId int, font *Font, fill *Fill, alignment *Alignment,
 		style:     newStyle,
 	}
 
-	// DefaultStyles = append(DefaultStyles, newStreamStyle)
 	return newStreamStyle
 }
 

+ 94 - 94
stream_style_test.go

@@ -10,7 +10,7 @@ import (
 )
 
 const (
-	StyleStreamTestsShouldMakeRealFiles = true
+	StyleStreamTestsShouldMakeRealFiles = false
 )
 
 type StreamStyleSuite struct{}
@@ -41,10 +41,10 @@ func (s *StreamSuite) TestXlsxStreamWriteWithStyle(t *C) {
 			},
 			workbookData: [][][]StreamCell{
 				{
-					{MakeStyledStringStreamCell("1", UnderlinedStrings), MakeStyledStringStreamCell("25", ItalicStrings),
-						MakeStyledStringStreamCell("A", BoldStrings), MakeStringStreamCell("B")},
-					{MakeIntegerStreamCell(1234), MakeStyledIntegerStreamCell(98, BoldIntegers),
-						MakeStyledIntegerStreamCell(34, ItalicIntegers), MakeStyledIntegerStreamCell(26, UnderlinedIntegers)},
+					{NewStyledStringStreamCell("1", UnderlinedStrings), NewStyledStringStreamCell("25", ItalicStrings),
+						NewStyledStringStreamCell("A", BoldStrings), NewStringStreamCell("B")},
+					{NewIntegerStreamCell(1234), NewStyledIntegerStreamCell(98, BoldIntegers),
+						NewStyledIntegerStreamCell(34, ItalicIntegers), NewStyledIntegerStreamCell(26, UnderlinedIntegers)},
 				},
 			},
 		},
@@ -55,10 +55,10 @@ func (s *StreamSuite) TestXlsxStreamWriteWithStyle(t *C) {
 			},
 			workbookData: [][][]StreamCell{
 				{
-					{MakeStringStreamCell("Token"), MakeStringStreamCell("Name"),
-						MakeStringStreamCell("Price"), MakeStringStreamCell("SKU")},
-					{MakeIntegerStreamCell(123), MakeStringStreamCell("Taco"),
-						MakeIntegerStreamCell(300), MakeIntegerStreamCell(123)},
+					{NewStringStreamCell("Token"), NewStringStreamCell("Name"),
+						NewStringStreamCell("Price"), NewStringStreamCell("SKU")},
+					{NewIntegerStreamCell(123), NewStringStreamCell("Taco"),
+						NewIntegerStreamCell(300), NewIntegerStreamCell(123)},
 				},
 			},
 		},
@@ -69,8 +69,8 @@ func (s *StreamSuite) TestXlsxStreamWriteWithStyle(t *C) {
 			},
 			workbookData: [][][]StreamCell{
 				{
-					{MakeStringStreamCell("Token")},
-					{MakeIntegerStreamCell(123)},
+					{NewStringStreamCell("Token")},
+					{NewIntegerStreamCell(123)},
 				},
 			},
 		},
@@ -81,34 +81,34 @@ func (s *StreamSuite) TestXlsxStreamWriteWithStyle(t *C) {
 			},
 			workbookData: [][][]StreamCell{
 				{
-					{MakeStringStreamCell("Token"), MakeStringStreamCell("Name"),
-						MakeStringStreamCell("Price"), MakeStringStreamCell("SKU")},
+					{NewStringStreamCell("Token"), NewStringStreamCell("Name"),
+						NewStringStreamCell("Price"), NewStringStreamCell("SKU")},
 
-					{MakeIntegerStreamCell(123), MakeStringStreamCell("Taco"),
-						MakeIntegerStreamCell(300), MakeIntegerStreamCell(123)},
+					{NewIntegerStreamCell(123), NewStringStreamCell("Taco"),
+						NewIntegerStreamCell(300), NewIntegerStreamCell(123)},
 				},
 				{
-					{MakeStringStreamCell("Token"), MakeStringStreamCell("Name"),
-						MakeStringStreamCell("Price"), MakeStringStreamCell("SKU"),
-						MakeStringStreamCell("Stock")},
+					{NewStringStreamCell("Token"), NewStringStreamCell("Name"),
+						NewStringStreamCell("Price"), NewStringStreamCell("SKU"),
+						NewStringStreamCell("Stock")},
 
-					{MakeIntegerStreamCell(456), MakeStringStreamCell("Salsa"),
-						MakeIntegerStreamCell(200), MakeIntegerStreamCell(346),
-						MakeIntegerStreamCell(1)},
+					{NewIntegerStreamCell(456), NewStringStreamCell("Salsa"),
+						NewIntegerStreamCell(200), NewIntegerStreamCell(346),
+						NewIntegerStreamCell(1)},
 
-					{MakeIntegerStreamCell(789), MakeStringStreamCell("Burritos"),
-						MakeIntegerStreamCell(400), MakeIntegerStreamCell(754),
-						MakeIntegerStreamCell(3)},
+					{NewIntegerStreamCell(789), NewStringStreamCell("Burritos"),
+						NewIntegerStreamCell(400), NewIntegerStreamCell(754),
+						NewIntegerStreamCell(3)},
 				},
 				{
-					{MakeStringStreamCell("Token"), MakeStringStreamCell("Name"),
-						MakeStringStreamCell("Price")},
+					{NewStringStreamCell("Token"), NewStringStreamCell("Name"),
+						NewStringStreamCell("Price")},
 
-					{MakeIntegerStreamCell(9853), MakeStringStreamCell("Guacamole"),
-						MakeIntegerStreamCell(500)},
+					{NewIntegerStreamCell(9853), NewStringStreamCell("Guacamole"),
+						NewIntegerStreamCell(500)},
 
-					{MakeIntegerStreamCell(2357), MakeStringStreamCell("Margarita"),
-						MakeIntegerStreamCell(700)},
+					{NewIntegerStreamCell(2357), NewStringStreamCell("Margarita"),
+						NewIntegerStreamCell(700)},
 				},
 			},
 		},
@@ -119,24 +119,24 @@ func (s *StreamSuite) TestXlsxStreamWriteWithStyle(t *C) {
 			},
 			workbookData: [][][]StreamCell{
 				{
-					{MakeStringStreamCell("Token"), MakeStringStreamCell("Name"),
-						MakeStringStreamCell("Price"), MakeStringStreamCell("SKU")},
+					{NewStringStreamCell("Token"), NewStringStreamCell("Name"),
+						NewStringStreamCell("Price"), NewStringStreamCell("SKU")},
 
-					{MakeIntegerStreamCell(123), MakeStringStreamCell("Taco"),
-						MakeIntegerStreamCell(300), MakeIntegerStreamCell(123)},
+					{NewIntegerStreamCell(123), NewStringStreamCell("Taco"),
+						NewIntegerStreamCell(300), NewIntegerStreamCell(123)},
 				},
 				{
-					{MakeStringStreamCell("Token"), MakeStringStreamCell("Name"),
-						MakeStringStreamCell("Price"), MakeStringStreamCell("SKU"),
-						MakeStringStreamCell("Stock")},
+					{NewStringStreamCell("Token"), NewStringStreamCell("Name"),
+						NewStringStreamCell("Price"), NewStringStreamCell("SKU"),
+						NewStringStreamCell("Stock")},
 
-					{MakeIntegerStreamCell(456), MakeStringStreamCell("Salsa"),
-						MakeIntegerStreamCell(200), MakeIntegerStreamCell(346),
-						MakeIntegerStreamCell(1)},
+					{NewIntegerStreamCell(456), NewStringStreamCell("Salsa"),
+						NewIntegerStreamCell(200), NewIntegerStreamCell(346),
+						NewIntegerStreamCell(1)},
 
-					{MakeIntegerStreamCell(789), MakeStringStreamCell("Burritos"),
-						MakeIntegerStreamCell(400), MakeIntegerStreamCell(754),
-						MakeIntegerStreamCell(3)},
+					{NewIntegerStreamCell(789), NewStringStreamCell("Burritos"),
+						NewIntegerStreamCell(400), NewIntegerStreamCell(754),
+						NewIntegerStreamCell(3)},
 				},
 			},
 			expectedError: fmt.Errorf("duplicate sheet name '%s'.", "Sheet 1"),
@@ -148,18 +148,18 @@ func (s *StreamSuite) TestXlsxStreamWriteWithStyle(t *C) {
 			},
 			workbookData: [][][]StreamCell{
 				{
-					{MakeStringStreamCell("Token"), MakeStringStreamCell("Name"),
-						MakeStringStreamCell("Price"), MakeStringStreamCell("SKU")},
+					{NewStringStreamCell("Token"), NewStringStreamCell("Name"),
+						NewStringStreamCell("Price"), NewStringStreamCell("SKU")},
 
-					{MakeIntegerStreamCell(123), MakeStringStreamCell("Taco"),
-						MakeIntegerStreamCell(300), MakeIntegerStreamCell(123)},
+					{NewIntegerStreamCell(123), NewStringStreamCell("Taco"),
+						NewIntegerStreamCell(300), NewIntegerStreamCell(123)},
 				},
 				{
-					{MakeStringStreamCell("Token"), MakeStringStreamCell("Name"),
-						MakeStringStreamCell("Price"), MakeStringStreamCell("SKU")},
+					{NewStringStreamCell("Token"), NewStringStreamCell("Name"),
+						NewStringStreamCell("Price"), NewStringStreamCell("SKU")},
 
-					{MakeIntegerStreamCell(456), MakeStringStreamCell("Salsa"),
-						MakeIntegerStreamCell(200), MakeIntegerStreamCell(346)},
+					{NewIntegerStreamCell(456), NewStringStreamCell("Salsa"),
+						NewIntegerStreamCell(200), NewIntegerStreamCell(346)},
 				},
 			},
 			expectedError: AlreadyOnLastSheetError,
@@ -171,12 +171,12 @@ func (s *StreamSuite) TestXlsxStreamWriteWithStyle(t *C) {
 			},
 			workbookData: [][][]StreamCell{
 				{
-					{MakeStringStreamCell("Token"), MakeStringStreamCell("Name"),
-						MakeStringStreamCell("Price"), MakeStringStreamCell("SKU")},
+					{NewStringStreamCell("Token"), NewStringStreamCell("Name"),
+						NewStringStreamCell("Price"), NewStringStreamCell("SKU")},
 
-					{MakeIntegerStreamCell(123), MakeStringStreamCell("Taco"),
-						MakeIntegerStreamCell(300), MakeIntegerStreamCell(123),
-						MakeStringStreamCell("asdf")},
+					{NewIntegerStreamCell(123), NewStringStreamCell("Taco"),
+						NewIntegerStreamCell(300), NewIntegerStreamCell(123),
+						NewStringStreamCell("asdf")},
 				},
 			},
 			expectedError: WrongNumberOfRowsError,
@@ -188,11 +188,11 @@ func (s *StreamSuite) TestXlsxStreamWriteWithStyle(t *C) {
 			},
 			workbookData: [][][]StreamCell{
 				{
-					{MakeStringStreamCell("Token"), MakeStringStreamCell("Name"),
-						MakeStringStreamCell("Price"), MakeStringStreamCell("SKU")},
+					{NewStringStreamCell("Token"), NewStringStreamCell("Name"),
+						NewStringStreamCell("Price"), NewStringStreamCell("SKU")},
 
-					{MakeIntegerStreamCell(123), MakeStringStreamCell("Taco"),
-						MakeIntegerStreamCell(300)},
+					{NewIntegerStreamCell(123), NewStringStreamCell("Taco"),
+						NewIntegerStreamCell(300)},
 				},
 			},
 			expectedError: WrongNumberOfRowsError,
@@ -204,14 +204,14 @@ func (s *StreamSuite) TestXlsxStreamWriteWithStyle(t *C) {
 			},
 			workbookData: [][][]StreamCell{
 				{
-					{MakeStringStreamCell("Token"), MakeStringStreamCell("Name"),
-						MakeStringStreamCell("Price"), MakeStringStreamCell("SKU")},
+					{NewStringStreamCell("Token"), NewStringStreamCell("Name"),
+						NewStringStreamCell("Price"), NewStringStreamCell("SKU")},
 
-					{MakeIntegerStreamCell(123), MakeStringStreamCell("Taco"),
-						MakeIntegerStreamCell(300), MakeIntegerStreamCell(123)},
+					{NewIntegerStreamCell(123), NewStringStreamCell("Taco"),
+						NewIntegerStreamCell(300), NewIntegerStreamCell(123)},
 				},
 				{{}},
-				{{MakeStringStreamCell("Id"), MakeStringStreamCell("Unit Cost")}},
+				{{NewStringStreamCell("Id"), NewStringStreamCell("Unit Cost")}},
 				{{}},
 				{{}},
 				{{}},
@@ -224,11 +224,11 @@ func (s *StreamSuite) TestXlsxStreamWriteWithStyle(t *C) {
 			},
 			workbookData: [][][]StreamCell{
 				{
-					{MakeStringStreamCell("Token"), MakeStringStreamCell("Name"),
-						MakeStringStreamCell("Price"), MakeStringStreamCell("SKU")},
+					{NewStringStreamCell("Token"), NewStringStreamCell("Name"),
+						NewStringStreamCell("Price"), NewStringStreamCell("SKU")},
 
-					{MakeIntegerStreamCell(123), MakeStringStreamCell("Taco"),
-						MakeIntegerStreamCell(300), MakeIntegerStreamCell(123)},
+					{NewIntegerStreamCell(123), NewStringStreamCell("Taco"),
+						NewIntegerStreamCell(300), NewIntegerStreamCell(123)},
 				},
 				{{}},
 			},
@@ -242,19 +242,19 @@ func (s *StreamSuite) TestXlsxStreamWriteWithStyle(t *C) {
 				{
 					// String courtesy of https://github.com/minimaxir/big-list-of-naughty-strings/
 					// Header row contains the tags that I am filtering on
-					{MakeStringStreamCell("Token"), MakeStringStreamCell(endSheetDataTag),
-						MakeStringStreamCell("Price"), MakeStringStreamCell(fmt.Sprintf(dimensionTag, "A1:D1"))},
+					{NewStringStreamCell("Token"), NewStringStreamCell(endSheetDataTag),
+						NewStringStreamCell("Price"), NewStringStreamCell(fmt.Sprintf(dimensionTag, "A1:D1"))},
 					// Japanese and emojis
-					{MakeIntegerStreamCell(123), MakeStringStreamCell("パーティーへ行かないか"),
-						MakeIntegerStreamCell(300), MakeStringStreamCell("🍕🐵 🙈 🙉 🙊")},
+					{NewIntegerStreamCell(123), NewStringStreamCell("パーティーへ行かないか"),
+						NewIntegerStreamCell(300), NewStringStreamCell("🍕🐵 🙈 🙉 🙊")},
 					// XML encoder/parser test strings
-					{MakeIntegerStreamCell(123), MakeStringStreamCell(`<?xml version="1.0" encoding="ISO-8859-1"?>`),
-						MakeIntegerStreamCell(300), MakeStringStreamCell(`<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE foo [ <!ELEMENT foo ANY ><!ENTITY xxe SYSTEM "file:///etc/passwd" >]><foo>&xxe;</foo>`)},
+					{NewIntegerStreamCell(123), NewStringStreamCell(`<?xml version="1.0" encoding="ISO-8859-1"?>`),
+						NewIntegerStreamCell(300), NewStringStreamCell(`<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE foo [ <!ELEMENT foo ANY ><!ENTITY xxe SYSTEM "file:///etc/passwd" >]><foo>&xxe;</foo>`)},
 					// Upside down text and Right to Left Arabic text
-					{MakeIntegerStreamCell(123), MakeStringStreamCell(`˙ɐnbᴉlɐ ɐuƃɐɯ ǝɹolop ʇǝ ǝɹoqɐl ʇn ʇunpᴉpᴉɔuᴉ ɹodɯǝʇ poɯsnᴉǝ op pǝs 'ʇᴉlǝ ƃuᴉɔsᴉdᴉpɐ ɹnʇǝʇɔǝsuoɔ 'ʇǝɯɐ ʇᴉs ɹolop ɯnsdᴉ ɯǝɹo˥
-					00˙Ɩ$-`), MakeIntegerStreamCell(300), MakeStringStreamCell(`ﷺ`)},
-					{MakeIntegerStreamCell(123), MakeStringStreamCell("Taco"),
-						MakeIntegerStreamCell(300), MakeIntegerStreamCell(123)},
+					{NewIntegerStreamCell(123), NewStringStreamCell(`˙ɐnbᴉlɐ ɐuƃɐɯ ǝɹolop ʇǝ ǝɹoqɐl ʇn ʇunpᴉpᴉɔuᴉ ɹodɯǝʇ poɯsnᴉǝ op pǝs 'ʇᴉlǝ ƃuᴉɔsᴉdᴉpɐ ɹnʇǝʇɔǝsuoɔ 'ʇǝɯɐ ʇᴉs ɹolop ɯnsdᴉ ɯǝɹo˥
+					00˙Ɩ$-`), NewIntegerStreamCell(300), NewStringStreamCell(`ﷺ`)},
+					{NewIntegerStreamCell(123), NewStringStreamCell("Taco"),
+						NewIntegerStreamCell(300), NewIntegerStreamCell(123)},
 				},
 			},
 		},
@@ -333,7 +333,7 @@ func writeStreamFileWithStyle(filePath string, fileBuffer io.Writer, sheetNames
 			colStyles = append(colStyles, cell.cellStyle)
 		}
 
-		err := file.AddSheetWithStyle(sheetName, colStyles)
+		err := file.AddSheetS(sheetName, colStyles)
 		if err != nil {
 			return err
 		}
@@ -354,7 +354,7 @@ func writeStreamFileWithStyle(filePath string, fileBuffer io.Writer, sheetNames
 			//if i == 0 {
 			//	continue
 			//}
-			err = streamFile.WriteWithStyle(row)
+			err = streamFile.WriteS(row)
 			if err != nil {
 				return err
 			}
@@ -377,8 +377,8 @@ func (s *StreamSuite) TestDates(t *C) {
 	sheetNames := []string{"Sheet1"}
 	workbookData := [][][]StreamCell{
 		{
-			{MakeStringStreamCell("Date:")},
-			{MakeDateStreamCell(time.Now())},
+			{NewStringStreamCell("Date:")},
+			{NewDateStreamCell(time.Now())},
 		},
 	}
 
@@ -409,8 +409,8 @@ func (s *StreamSuite) TestMakeNewStylesAndUseIt(t *C) {
 	sheetNames := []string{"Sheet1"}
 	workbookData := [][][]StreamCell{
 		{
-			{MakeStringStreamCell("Header1"), MakeStringStreamCell("Header2")},
-			{MakeStyledStringStreamCell("Good", greenStyle), MakeStyledStringStreamCell("Bad", redStyle)},
+			{NewStringStreamCell("Header1"), NewStringStreamCell("Header2")},
+			{NewStyledStringStreamCell("Good", greenStyle), NewStyledStringStreamCell("Bad", redStyle)},
 		},
 	}
 
@@ -455,8 +455,8 @@ func (s *StreamSuite) TestCloseWithNothingWrittenToSheetsWithStyle(t *C) {
 
 	sheetNames := []string{"Sheet1", "Sheet2"}
 	workbookData := [][][]StreamCell{
-		{{MakeStringStreamCell("Header1"), MakeStringStreamCell("Header2")}},
-		{{MakeStringStreamCell("Header3"), MakeStringStreamCell("Header4")}},
+		{{NewStringStreamCell("Header1"), NewStringStreamCell("Header2")}},
+		{{NewStringStreamCell("Header3"), NewStringStreamCell("Header4")}},
 	}
 
 	defaultStyles := []StreamStyle{Strings, BoldStrings, ItalicIntegers, UnderlinedStrings,
@@ -477,11 +477,11 @@ func (s *StreamSuite) TestCloseWithNothingWrittenToSheetsWithStyle(t *C) {
 		colStyles1 = append(colStyles1, cell.cellStyle)
 	}
 
-	err = file.AddSheetWithStyle(sheetNames[0], colStyles0)
+	err = file.AddSheetS(sheetNames[0], colStyles0)
 	if err != nil {
 		t.Fatal(err)
 	}
-	err = file.AddSheetWithStyle(sheetNames[1], colStyles1)
+	err = file.AddSheetS(sheetNames[1], colStyles1)
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -522,11 +522,11 @@ func (s *StreamSuite) TestBuildErrorsAfterBuildWithStyle(t *C) {
 		t.Fatal(err)
 	}
 
-	err = file.AddSheetWithStyle("Sheet1", []StreamStyle{Strings})
+	err = file.AddSheetS("Sheet1", []StreamStyle{Strings})
 	if err != nil {
 		t.Fatal(err)
 	}
-	err = file.AddSheetWithStyle("Sheet2", []StreamStyle{Strings})
+	err = file.AddSheetS("Sheet2", []StreamStyle{Strings})
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -552,11 +552,11 @@ func (s *StreamSuite) TestAddSheetWithStyleErrorsAfterBuild(t *C) {
 		t.Fatal(err)
 	}
 
-	err = file.AddSheetWithStyle("Sheet1", []StreamStyle{Strings})
+	err = file.AddSheetS("Sheet1", []StreamStyle{Strings})
 	if err != nil {
 		t.Fatal(err)
 	}
-	err = file.AddSheetWithStyle("Sheet2", []StreamStyle{Strings})
+	err = file.AddSheetS("Sheet2", []StreamStyle{Strings})
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -565,7 +565,7 @@ func (s *StreamSuite) TestAddSheetWithStyleErrorsAfterBuild(t *C) {
 	if err != nil {
 		t.Fatal(err)
 	}
-	err = file.AddSheetWithStyle("Sheet3", []StreamStyle{Strings})
+	err = file.AddSheetS("Sheet3", []StreamStyle{Strings})
 	if err != BuiltStreamFileBuilderError {
 		t.Fatal(err)
 	}

+ 0 - 15
write.go

@@ -63,21 +63,6 @@ func (r *Row) WriteSlice(e interface{}, cols int) int {
 	return i
 }
 
-// WriteCellSlice an array of Cell's to row r. Accepts an array of StreamCells
-// and writes the number of columns to write, 'cols'. If 'cols' is < 0,
-// the entire array will be written if possible. Returns the number of columns written.
-func (r *Row) WriteCellSlice(streamCells []StreamCell, cols int) int {
-	if cols == 0 {
-		return cols
-	}
-	i := 0
-	for _, streamCell := range streamCells {
-		r.AddStreamCell(streamCell)
-		i++
-	}
-	return i
-}
-
 // Writes a struct to row r. Accepts a pointer to struct type 'e',
 // and the number of columns to write, `cols`. If 'cols' is < 0,
 // the entire struct will be written if possible. Returns -1 if the 'e'